473,770 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Receive notification when errors occurs

Hello!

Is it possible for IIS to send some sort of notification when an ASP
error occurs on a page?

I can see them in the web logs, but I was wondering if there was a way
to receive an email or some other alert...

I thought about using CDO Send Mail, but this object is often what
cause the error in the first place.

Any suggestion?

Thanks in advance.

Bruno G.
Jul 21 '05 #1
3 1777
Yes, by implemeting a custom "500" page for your site or application in IIS.
Then you can have an ASP page handle the 500 errors with code such as this:

<%
Option Explicit

Response.Clear
Response.Status = 500

Dim sUrlRequested, sRedirect, sPath
Dim aVars, aPostData, aCookies, aQuerystring


Function GetErrorInfo
Dim aErrorInfo(1,13 )
Dim oError
Set oError = Server.GetLastE rror

aErrorInfo(0,0) = "ASP Code" : aErrorInfo(1,0) = oError.ASPCode
aErrorInfo(0,1) = "ASP Description" : aErrorInfo(1,1) =
oError.ASPDescr iption
aErrorInfo(0,2) = "Descriptio n" : aErrorInfo(1,2) = oError.Descript ion
aErrorInfo(0,3) = "Category" : aErrorInfo(1,3) = oError.Category
aErrorInfo(0,4) = "Number" : aErrorInfo(1,4) = oError.Number
aErrorInfo(0,5) = "Source" : aErrorInfo(1,5) = oError.Source
aErrorInfo(0,6) = "File" : aErrorInfo(1,6) = oError.File
aErrorInfo(0,7) = "Line" : aErrorInfo(1,7) = oError.Line
aErrorInfo(0,8) = "Querystrin g" : aErrorInfo(1,8) = Request.Queryst ring
On Error Resume Next
aErrorInfo(0,9) = "Form Data" : aErrorInfo(1,9) = Request.Form
If Err.Number <> 0 Then aErrorInfo(0,9) = "(binary data)"
On Error Goto 0
aErrorInfo(0,10 ) = "All HTTP" : aErrorInfo(1,10 ) = "<textarea
style=""width: 410px; height=100px; font: 8pt verdana;"">" &
Request.ServerV ariables("ALL_H TTP") & "</textarea>"
aErrorInfo(0,11 ) = "Remote Address" : aErrorInfo(1,11 ) =
Request.ServerV ariables("REMOT E_ADDR")
aErrorInfo(0,12 ) = "Descriptio n" : aErrorInfo(1,12 ) =
Request.ServerV ariables("REMOT E_HOST")
aErrorInfo(0,13 ) = "Request Date" : aErrorInfo(1,13 ) = FormatDateTime( Now,
1) & " " & FormatDateTime( Now, 3)

' "Safen" form data and all HTTP

If Len(aErrorInfo( 1,9)) > 50 Then aErrorInfo(1,9) = "&nbsp;<textare a
style=""width: 410px; height=100px; font: 8pt verdana;"">" & aErrorInfo(1,9)
& "</textarea>"
If Len(aErrorInfo( 1,10)) > 50 Then aErrorInfo(1,10 ) = "&nbsp;<textare a
style=""width: 410px; height=100px; font: 8pt verdana;"">" &
aErrorInfo(1,10 ) & "</textarea>"
GetErrorInfo = aErrorInfo
End Function


sPath = Replace(sUrlReq uested, "http://" &
Request.ServerV ariables("SERVE R_NAME"), "")
Call SendAlert(sUrlR equested, sRedirect)
Call General500()
Call DumpInfo()

%>
<% Sub General500() %>

<strong>Oops! An error has occurred, and the page you requested
cannot be loaded.</strong><br />
The page you requested is unavailable at the moment. An alert has been
sent to the
webmaster and this should be corrected soon. Please check back later.

<% End Sub %>

<%
Sub DumpInfo()
Dim i, aErrors, sBGColor
aErrors = GetErrorInfo
%>
<table width="100%" bgcolor="#00000 0" cellpadding="0" cellspacing="0" >
<tr bgcolor="#FFFFF F">
<td align="center"> <strong>Error Information</strong></td>
</tr>

<tr>
<td>
<table width="100%" align="center" cellpadding="3" cellspacing="1" >
<% For i = 0 To UBound(aErrors, 2)
If i Mod 2 = 0 Then
sBGColor = "#FFFFFF"
Else
sBGColor = "#EEEEEE"
End If
%>
<tr bgcolor="<%=sBG Color%>">
<td width="120" valign="top" align="right">< %=aErrors(0,i)% >:</td>
<td><font size="1"><%=aEr rors(1,i)%></font></td>
</tr>
<% Next %>
</table>
</td>
</tr>
</table>
<br />
<% End Sub %>
<%
Function GetServerVariab les()
Dim aVars(), sVar, i
i = 0
For Each sVar in Request.ServerV ariables
Redim Preserve aVars(1,i)
aVars(0,i) = sVar
aVars(1,i) = Request.ServerV ariables(sVar)
Next
GetServerVariab les = aVars
End Function
Function GetQuerystring( )
Dim aVars, sName, i
GetQuerystring = ""
i = 0
If Len(Request.Que rystring) > 0 Then
For Each sName In Request.Queryst ring
Redim Preserve aVars(1,i)
aVars(0,i) = sName
aVars(1,i) = Request.Queryst ring(sName)
Next
GetQuerystring = aVars
End If
End Function
%>
<% Response.End %>



<%
Sub SendAlert(URL, Redirect)

Dim sUrlRequested, sReferer, sPath
Dim oCDO, sMessage, aErrorInfo, i

sReferer = Request.ServerV ariables("HTTP_ REFERER")
sMessage = "Dear Webmaster," & vbCrlf & vbCrLf
sMessage = sMessage & "The following page request was made on the
[sitename], but the page generated an error. Please check the code for
coder error." & vbCrLf & vbCrLf
sMessage = sMessage & "URL Requested: " & URL & vbCrLf
sMessage = sMessage & "Referring URL: " & sReferer & vbCrLf
sMessage = sMessage & "Requester IP : " &
Request.ServerV ariables("REMOT E_ADDR") & vbCrLf
sMessage = sMessage & "Requested ID : " &
Request.ServerV ariables("AUTH_ USER") & vbCrLf & vbCrLf
sMessage = sMessage & String(50,"-") & vbCrLf
sMessage = sMessage & "Debug Info:" & vbCrLf & vbCrLf
aErrorInfo = GetErrorInfo
For i = 0 To UBound(aErrorIn fo, 2)
sMessage = sMessage & aErrorInfo(0,i) & ":" & vbCrLf & aErrorInfo(1,i) &
vbCrLf & vbCrLf
Next

sPath = Replace(URL, "http://" & Request.ServerV ariables("SERVE R_NAME"),
"")



Set oCDO = Server.CreateOb ject("CDO.Messa ge")
oCDO.From = "webserver@mydo main"
oCDO.To = "me@mydomai n"
oCDO.Subject = "500 Error on Website - " &
Request.ServerV ariables("REMOT E_ADDR")
oCDO.TextBody = sMessage
oCDO.Send
Set oCDO = Nothing

End Sub
%>


Ray at work







"Bruno G." <so***@no.spa m> wrote in message
news:OB******** ******@TK2MSFTN GP11.phx.gbl...
Hello!

Is it possible for IIS to send some sort of notification when an ASP
error occurs on a page?

I can see them in the web logs, but I was wondering if there was a way
to receive an email or some other alert...

I thought about using CDO Send Mail, but this object is often what
cause the error in the first place.

Any suggestion?

Thanks in advance.

Bruno G.

Jul 21 '05 #2
Thanks for the code... but what if the 500 error was caused by the Send
method of the CDO.Message object in another ASP page?
Won't this email fail as well?

Bruno

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:O4******** ******@TK2MSFTN GP12.phx.gbl...
Yes, by implemeting a custom "500" page for your site or application in
IIS. Then you can have an ASP page handle the 500 errors with code such as
this:
<snipped code>
Ray at work

"Bruno G." <so***@no.spa m> wrote in message
news:OB******** ******@TK2MSFTN GP11.phx.gbl...
Hello!

Is it possible for IIS to send some sort of notification when an ASP
error occurs on a page?

I can see them in the web logs, but I was wondering if there was a way
to receive an email or some other alert...

I thought about using CDO Send Mail, but this object is often what
cause the error in the first place.

Any suggestion?

Thanks in advance.

Bruno G.


Jul 21 '05 #3
So what do you want to happen? Obviously email is out.

Write to a text file, event log, or database.

Jeff

"Bruno G." <so***@no.spa m> wrote in message
news:OJ******** ******@TK2MSFTN GP14.phx.gbl...
Thanks for the code... but what if the 500 error was caused by the Send
method of the CDO.Message object in another ASP page?
Won't this email fail as well?

Bruno

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:O4******** ******@TK2MSFTN GP12.phx.gbl...
Yes, by implemeting a custom "500" page for your site or application in
IIS. Then you can have an ASP page handle the 500 errors with code such as this:

<snipped code>

Ray at work

"Bruno G." <so***@no.spa m> wrote in message
news:OB******** ******@TK2MSFTN GP11.phx.gbl...
Hello!

Is it possible for IIS to send some sort of notification when an ASP
error occurs on a page?

I can see them in the web logs, but I was wondering if there was a way
to receive an email or some other alert...

I thought about using CDO Send Mail, but this object is often what
cause the error in the first place.

Any suggestion?

Thanks in advance.

Bruno G.



Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1387
by: Tim O'Connell | last post by:
Hi, I'm using Python 2.3 on a Win XP box, and I'm trying to find if there's a library of some sort that will give you a callback (or something comparable) when a new disc is inserted into a CD Rom drive. I've done a little googling and nothing's come up, so I'm not holding my breath. :) If not, I'm thinking of implementing a thread to periodically read the volume serial number using GetVolumeInformation from Mark Hammond's Win 32...
1
1682
by: Paul F. Williams | last post by:
Is there a way to determine when the system has performed a garbage collection? I would like to be able to write a console message when the CLR performs a GC. Knowing when a GC happens might help me debug some odd problems.
6
3146
by: Daniel Rimmelzwaan | last post by:
I want to send a biztalk document to an aspx page, and I need to see some sample code, because I just can't make it work. I have a port with transport type HTTP, pointing to my aspx page, something like http://myserver/mypage.aspx. From there it gets blurry, because I just can't figure out how to do the rest. Does anybody have a sample page for me that I can take a look at? Just a simple one that takes whatever biztalk sends and saves it...
6
17205
by: ransoma22 | last post by:
I developing an application that receive SMS from a connected GSM handphone, e.g Siemens M55, Nokia 6230,etc through the data cable. The application(VB.NET) will receive the SMS automatically, process and output to the screen in my application when a message arrived. But the problem is how do I read the SMS message immediately when it arrived without my handphone BeEPINg for new message ? I read up the AT commands, but when getting down...
0
1479
by: Eron Wright | last post by:
We heavily use the ASP.NET Cache with file dependencies. The files are located in approximately 200 directories (I understand that monitoring largely occurs on a per-directory basis). As of late the worker process has been shutting down unexpectedly. The shutdown message is: "Overwhelming Change Notification in Overwhelming Change Notification in ..." To clarify, the shutdown message consists of many concatenated "Overwhelming
2
2153
by: cjard | last post by:
Suppose: A TextBox is bound to a BindingSource, which is bound to a DataTable A BindingNavigator is used to alter the current row being looked at by the BindingSource (i.e. Nav's NEXT button is pressed. BS.Position changes from 2 to 3, Textbox was showing APPLE, now shows ORANGE) Does the textbox receive any notification that this occurred? If so, what?
1
3851
by: rahul2sms | last post by:
Hello frd, I am writing a C# program to send & receive SMS. I am able to send SMS & read SMS from inbox through this program. But problem is that when a new message comes it do not shows it automatically. Because mobile phone do not sends any notification message to program. For example, when a phon call comes, then mobile-phone sends a "RING" notification to my program. But when new SMS comes. It do not sends any notification to my...
1
1341
by: Ben white | last post by:
I did this before but can't remember how - please help. This is the context: 1) .NET 1.1 2) Main form has a Task List Box, Go button, Cancel Button, Errors List Box 3) Task list may have 1 to n tasks described 4) Tasks may be long running 5) When task launches it shows a "progress form" and closes it when the task is complete 6) There is a Job object that performs the task.
1
2612
by: firstposter | last post by:
Hello Is there an easy way to capture ALL(or most) site errors I'm running a site which uses apache, php5 and mysql I'm wanting to be automatically notified via email when the following occurs on the site: - php errors - mysql errors
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10037
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8931
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.