|
Dim objErrorInfo
Set objErrorInfo = Server.GetLastError
ErrTxt = ErrTxt & "ASPCode = " & objErrorInfo.ASPCode & vbCrLf
ErrTxt = ErrTxt & "ASPDescription = " & objErrorInfo.ASPDescription & vbCrLf
ErrTxt = ErrTxt & "Category = " & objErrorInfo.Category & vbCrLf
ErrTxt = ErrTxt & "Column = " & objErrorInfo.Column & vbCrLf
ErrTxt = ErrTxt & "Description = " & objErrorInfo.Description & vbCrLf
ErrTxt = ErrTxt & "File = " & objErrorInfo.File & vbCrLf
ErrTxt = ErrTxt & "Line = " & objErrorInfo.Line & vbCrLf
ErrTxt = ErrTxt & "Number = " & objErrorInfo.Number & vbCrLf
ErrTxt = ErrTxt & "Source = " & objErrorInfo.Source & vbCrLf
Set objErrMail= Server.CreateObject("CDO.Message")
With objErrMail
.From = "webmaster@YOURSERVER.com"
.To = "webmaster@YOURSERVER.com"
.Subject = "Alert - 500 Error"
.TextBody = ErrTxt
.Send
End With
Set objErrMail = Nothing
If you want to, you can also add in a command to display the error as a hidden comment. Note that this could help hackers, who then view your code to see it! But when you're actively testing, this can help you faster than waiting for the mail messages to come in to you. So the code you would add would say:
response.write "<!-- " & ErrTxt & " -->"
Now to actually have this page SHOW when a user gets a 500 error on your site. If you have control over your own server settings, you would make this change yourself in IIS. If you do not, ask your hosting company to make this IIS change for you.
* Go into the IIS Manager
* Click on the icon for your website
* Right click and choose PROPERTIES
* Click on the CUSTOM ERRORS tab
* Scroll down until you see the entry for error 404
* Click on that line and click the EDIT PROPERTIES tab
* choose URL in the MESSAGE TYPE dropdown
* put in /500.asp as the filename
Save and exit! Now any time you get an ASP error on your site it will go to the 500.asp page you have made. You can make that page as pretty or complex as you wish. You can in fact simply have that page have code to redirect the user back to your site homepage.
ASP Server Setup Information
|
Ebooks Intro to ASP ASP SQL DB Members Shopping
Romance Tips Irish Romance Italian Romance French Romance
|