Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 5th, 2004, 01:58 PM
Authorized User
 
Join Date: Sep 2004
Posts: 62
Thanks: 0
Thanked 1 Time in 1 Post
Default ASP Error Trapping and Reporting

Does anyone know of any simple code that can trap unhandles server errors? I want to just through a sub on a bunch of pages that trap any unhandled IIS errors that will create an email and notify me of the exact error message but I don't have the ability to edit the global.asa file or anything....

Anyone know of anything?
 
Old November 6th, 2004, 05:29 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Hello kevokiran,

Do you have access to the server ? If yes, you can do the following.

Create a custom error page for the site. You can copy the basic template of the site and include error information into it to create one such page.

Here is a sample page.

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title>Error reported</title>
    </head>

    <body>
        <h3>This page has produced an error</h3>
        <p>The description of the error is given below.</p>
        <%
            Dim objASPError
            Set objASPError=Server.GetLastError
            Response.Write("<strong>Error number</strong> = " & objASPError.Number & "<br>")
            Response.Write("<strong>File</strong> = " & objASPError.File & "<br>")
            Response.Write("<strong>Line  number</strong> = " & objASPError.Line & "<br>")
            Response.Write("<strong>Column</strong> = " & objASPError.Column & "<br>")
            Response.Write("<strong>Description:</strong><br>" & Server.HTMLEncode(objASPError.Description) & "<br>")
        %>
    </body>
</html>
This is a bare minimum report. You can take a look at /iishelp/custom/500-100.asp to get all the properties of error object. You may mail this error to an address if you prefer.

Now, you have to configure IIS to use this file.

First upload the custom error page to a folder.

Open IIS Manager.

Rightclick the virtual directory corresponding to the site. Open properties.

Open the tab - custom errors.

Scroll down to the error 500;100. Edit it.

Choose the type as URL. Give the URL of your custom error page for that error. User the above file you created.

Now you can see, it shows the page you have created whenever an error happens.

If server is not in your control, you can create the file and upload it to a folder and request these configuration changes to server admin. (Best of luck !)

Hope this helps.

Madhu.
 
Old November 9th, 2004, 12:46 PM
Authorized User
 
Join Date: Sep 2004
Posts: 62
Thanks: 0
Thanked 1 Time in 1 Post
Default

You are the man! Thanks a million!

 
Old June 2nd, 2007, 02:08 PM
Registered User
 
Join Date: Jun 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How this can be done if my site is in shared hosting?

thanks
Dosth






Similar Threads
Thread Thread Starter Forum Replies Last Post
error reporting - oddity ab_dev Beginning PHP 1 March 13th, 2006 02:44 PM
error trapping majones@omaha Classic ASP Basics 0 January 5th, 2006 02:02 PM
Trapping Application Events ERROR MagicTH Excel VBA 1 August 14th, 2005 01:23 PM
Need some error trapping... cpk Classic ASP Databases 4 January 26th, 2005 08:10 AM
Error Trapping Steps jweyl SQL Server DTS 1 July 26th, 2004 05:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.