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) = " <textare a
style=""width: 410px; height=100px; font: 8pt verdana;"">" & aErrorInfo(1,9)
& "</textarea>"
If Len(aErrorInfo( 1,10)) > 50 Then aErrorInfo(1,10 ) = " <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.