Click here to Skip to main content
Click here to Skip to main content
Go to top

Trap ASP and SQL errors in your site

, 25 Apr 2002
Rate this:
Please Sign up or sign in to vote.
Trap the ASP and SQL errors in your Site

Introduction

This article shows you how to trap the ASP & SQL errors in your site.

First thing to do is to change the Custom Error for The Web Site Properties
[Internal Server Error] - HTTP Error 500 & 500;5001 to this URL -> /trap.asp 

Now create the trap.asp file using the code shown below.

Code Listing

<%
Const lngMaxFormBytes = 200

Response.Buffer = true

If Response.Buffer Then
    Response.Clear
    Response.Status = "500 Internal Server Error"
    Response.ContentType = "text/html"
    Response.Expires = 0
End If

Set objASPError = Server.GetLastError

strServername     = LCase(Request.ServerVariables("SERVER_NAME"))
strServerIP     = Request.ServerVariables("LOCAL_ADDR")
strRemoteIP     = Request.ServerVariables("REMOTE_ADDR")
strCategory     = objASPError.Category
strASPCode     = Server.htmlEncode(objASPError.ASPCode)
intNumber     = objASPError.Number
strFile         = objASPError.File
intLine         = objASPError.Line
intColumn     = objASPError.Column
strSource     = server.htmlEncode(objASPError.Source)
strDescription     = Replace(Server.htmlEncode( _
    objASPError.Description),"'","-")
strASPDescription= Replace(Server.htmlEncode( _
    objASPError.ASPDescription),"'","-")

Response.Write "Sorry, but the site is not available."
%>

You could send the email to the webmaster, with the error.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Fernando Finelli
Web Developer
Argentina Argentina
Lic. Fernando Finelli

Comments and Discussions

 
QuestionHow it go to error section in asp error trap Pinmemberanil12398@yahoo.co.in15-Jan-07 18:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 26 Apr 2002
Article Copyright 2002 by Fernando Finelli
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid