Creating a Helpful 500 Page
A 500 page warns you of errors - and alerts you when hackers try to get into your system. Here is how to make a helpful 500 page.
First, create a simple page and call it 500.asp. It's best to just put it in your root directory of your website. Have it say something like "The page you found is not available, please choose from this list of other commonly requested pages" and then add links to a few of your most popular pages.
But more importantly is what this page DOES for you. You need to know when you have database / ASP errors on your site. It could be a typo you've made - or it could be a hacker trying to break into your system! Add this ASP code.
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
All content copyright © 2013 Minerva WebWorks LLC. All rights reserved.