Link to home
Start Free TrialLog in
Avatar of harris9999
harris9999Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Report Classic ASP 500 Error on IIS7

I have a website in classic asp on IIS7.
I want to be emailed when an asp error occurs.

I can't get it working correctly.

Latest method I've tried:
for the site on IIS I have added an error page with
Status Code: 500.100 to go to my error page: /500-error/

But I just get the detailed error in the browser when it happens.
Edit Feature Settings Displays - Detailed Error for local requests and custom for remote.

how do I set this up or is there a better method?


My custom page is below.


<%
  'Option Explicit
  On Error Resume Next
  Response.Clear
  Dim objError
  Set objError = Server.GetLastError()
%>
<%

errmess=""
errmess=errmess & "<table>" & vbcrlf

 If Len(CStr(objError.ASPCode)) > 0 Then
    errmess=errmess & "  <tr>" & vbcrlf
    errmess=errmess & "    <th>IIS Error Number</th>" & vbcrlf
    errmess=errmess & "    <td>" & objError.ASPCode & "</td>" & vbcrlf
    errmess=errmess & "  </tr>" & vbcrlf
End If
If Len(CStr(objError.Number)) > 0 Then 
    errmess=errmess & "  <tr>" & vbcrlf
    errmess=errmess & "    <th>COM Error Number</th>" & vbcrlf
    errmess=errmess & "    <td>" & objError.Number & "" & " (0x" & Hex(objError.Number) & ")" & "</td>" & vbcrlf
    errmess=errmess & "  </tr>" & vbcrlf
End If
If Len(CStr(objError.Source)) > 0 Then
    errmess=errmess & "  <tr>" & vbcrlf
    errmess=errmess & "    <th>Error Source</th>" & vbcrlf
    errmess=errmess & "    <td>" & objError.Source & "</td>" & vbcrlf
    errmess=errmess & "  </tr>" & vbcrlf
End If
If Len(CStr(objError.File)) > 0 Then
    errmess=errmess & "  <tr>" & vbcrlf
    errmess=errmess & "    <th>File Name</th>" & vbcrlf
    errmess=errmess & "    <td>" & objError.File & "</td>" & vbcrlf
    errmess=errmess & "  </tr>" & vbcrlf
End If
If Len(CStr(objError.Line)) > 0 Then
    errmess=errmess & "  <tr>" & vbcrlf
    errmess=errmess & "    <th>Line Number</th>" & vbcrlf
    errmess=errmess & "    <td>" & objError.Line & "</td>" & vbcrlf
    errmess=errmess & "  </tr>" & vbcrlf
End If
If Len(CStr(objError.Description)) > 0 Then 
	errmess=errmess & "  <tr>" & vbcrlf
	errmess=errmess & "    <th>Brief Description</th>" & vbcrlf
	errmess=errmess & "    <td>" & objError.Description & "</td>" & vbcrlf
	errmess=errmess & "  </tr>" & vbcrlf
End If
If Len(CStr(objError.ASPDescription)) > 0 Then 
    errmess=errmess & "  <tr>" & vbcrlf
    errmess=errmess & "    <th>Full Description</th>" & vbcrlf
    errmess=errmess & "    <td>" & objError.ASPDescription & "</td>" & vbcrlf
    errmess=errmess & "  </tr>" & vbcrlf
 End If
errmess=errmess & "<table>"


Set NewMailObj=CreateObject("CDO.Message")
NewMailObj.From = fromaddress
NewMailObj.To = toaddress
NewMailObj.Bcc = contactbcc
NewMailObj.Subject = "500 Error" 
NewMailObj.HTMLBody = errmess
			
NewMailObj.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
NewMailObj.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
="localhost"

'Server port
NewMailObj.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
=25 
NewMailObj.Configuration.Fields.Update
			
NewMailObj.Send
Set NewMailObj = nothing



 %>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of pateljitu
pateljitu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial