?
Solved

Classic ASP script errors cause IIS to generate e-mail message

Posted on 2011-10-07
6
Medium Priority
?
412 Views
Last Modified: 2012-05-12
Years ago, somebody helped me set this up, but now I can't remember how we did it.

I setup my website in IIS using (I think) the Custom Errors tab, so that ASP errors would call an ASP script, which itself contained code that generated an e-mail message, sending details of the error message to my e-mail address. This so that I would be aware if users are getting errors on the site, so I can be notified and look into the problem.

I assume there is a relatively easy way to do this? Thank you!
0
Comment
Question by:bbdesign
  • 4
6 Comments
 
LVL 15

Accepted Solution

by:
pateljitu earned 2000 total points
ID: 36932912
Please see these article for reference:

http://www.iislogs.com/steveschofield/custom-errors-error-pages-500-100-asp-classic-asp-and-iis-7-0

http://www.15seconds.com/issue/990603.htm

Basically you would need these steps:
1. Setup customer error page on IIS for 500 error, say that page you point to is called errorpage.asp
2. In errorpage.asp write a mailer program using CDO to send error occurred with reference to code
Set objErrorInfo = Server.GetLastError

strEmailBody = "<b>ASPCode</b> = "& objErrorInfo.ASPCode & "<br>" _
    & "<b>ASPDescription</b> = "& objErrorInfo.ASPDescription & "<br>" _
    & "<b>Category</b> = "& objErrorInfo.Category & "<br>" _
    & "<b>Column</b> = "& objErrorInfo.Column & "<br>" _
    & "<b>Description</b> = "& objErrorInfo.Description& "<br>" _
    & "<b>File</b> = "& objErrorInfo.File & "<br>" _
    & "<b>Line</b> = "& objErrorInfo.Line & "<br>" _
    & "<b>Number</b> = "& objErrorInfo.Number & "<br>" _
    & "<b>Source</b> = "& objErrorInfo.Source & "<br>" _
    & "<b>HTTP HEADER</b> = "& Request.ServerVariables("ALL_HTTP") & "<br>"

3. After email is sent display friendly error message on page

Sorry, an error has occurred. An error occurred on the server when processing the request. Please try your request again.

Hope this help.
0
 

Author Comment

by:bbdesign
ID: 36933181
OK, thanks. Please see attached screenshot. The previous value was:

500 / Default / "Internal Server Error"

I changed it to point to the default 500 ASP script. I figured I could just add my e-mail code to that. However, when I purposely generate an error, for some reason, my browser downloads the ASP script instead of loading it in the window! I can't understand that one.

You can try it here yourself, if you want:

http://www.bbdesign.com/error.asp

How can I make the ASP script render in the browser instead of downloading? Thank you!
1.jpg
0
 
LVL 18

Expert Comment

by:nap0leon
ID: 36933214
Quick guess...
Move your 500-100.asp page to underneath your www folder.
(I've always placed these files into a folder under IIS, e.g., c:\inetpub\wwwroot\errors\400.asp)
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 

Author Comment

by:bbdesign
ID: 36933273
That didn't fix it. I thought maybe changing the message type to URL instead of File would do it, but I can't just reference a local path to it using C:\... etc., can I? It is making me put a valid URL in instead of a path name.

This is kind of ridiculous, no other ASP page on the server downloads, they all render, and this is in the same directory as other ASP scripts.
0
 

Author Comment

by:bbdesign
ID: 36933529
I think I got this to work, hold on.
0
 

Author Comment

by:bbdesign
ID: 36933546
I changed the Message Type from File to URL, and inserted this:

/500-100.asp

Now it works. However, I was hoping to use this script for several websites and would like to store it in a central location. But the user could be browsing a page at any number of different folder levels. Is it possible to use the type of URL above, except starting from a specific location, such as c:\... etc.?
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
A phishing scam that claims a recipient’s credit card details have been “suspended” is the latest trend in spoof emails.
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
Watch the video to learn how one can deal with PST file corruption issue with an outstanding Kernel for Outlook PST Repair Tool easily. Using this tool, non-technical users can swiftly perform the repair process to restore their essential data witho…
Suggested Courses

601 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