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

Posted on 2011-10-07
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!
Question by:bbdesign
    LVL 15

    Accepted Solution

    Please see these article for reference:

    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.

    Author Comment

    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:

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

    Expert Comment

    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)

    Author Comment

    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.

    Author Comment

    I think I got this to work, hold on.

    Author Comment

    I changed the Message Type from File to URL, and inserted this:


    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.?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    What is an ISAPI filter?   •      It's an assembly (.dll file) that can add or change the way IIS works.   •      They can be enabled globally for your web server or on a site-by-site basis.   When the IIS server receives a request, enabling the ISAPI fi…
    I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now