?
Solved

Report Classic ASP 500 Error on IIS7

Posted on 2011-10-13
1
Medium Priority
?
527 Views
Last Modified: 2012-05-12
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

0
Comment
Question by:harris9999
1 Comment
 
LVL 15

Accepted Solution

by:
pateljitu earned 2000 total points
ID: 36962553
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
A phishing scam that claims a recipient’s credit card details have been “suspended” is the latest trend in spoof emails.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Screencast - Getting to Know the Pipeline

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question