I recently started using GoDaddy for hosting some of my websites as I developed a CMS system that I wanted to confirm played well on their systems.
One snag I ran in to was setting up Custom Error Pages, not just simply displaying the error message intead of the default IIS message – actually displaying a page of my own devising so I could have it send me an email to let me know the site had experienced an error.
Configuring custom 404 pages is simple and is done from within the GoDaddy control panel but there was no option for server errors (500 errors) so I contacted GoDaddy and got this fairly unhelpful response:
Dear Bob,
Thank you for contacting Online Support.
I understand you need assistance with trying to have a custom page to process errors. This process is going to be possible, however you are going to need to make the changes inside of you web.config file. Since this has to deal with 3rd party scripting we would not be able to help with the scripting of the web.config. The process is only going to be able to completed in a web.config file, nothing inside of our interface will help with what you are trying to accomplish.
Please let us know if we can assist you in any other way.
Regards,
Adrian P.
Online Support
So effectively they are saying ‘I know the answer but I’m not going to tell you’, despite the fact I’ve seen them help others (although we do not support custom scripting, I did take look at your Web.config file to ensure you had added the code required for IIS 7 to display the errors).
In the end after scouring a few different threads I cam up with the following, simply ensure that your web.config file contains the following:
A Sample ASP VBScript Error Handler
The error handler below is pretty primitive but worked for my needs – it gathers only the most useful debugging information server object (line number, error description, file name, IP address, etc.), it then checks for any submitted querystring or posted values and finally it lists the name and value of any session variables at the time of the error.
Danger Danger!
Now the temptation is to simply generate and show the error whenever your website encounters a problem but this exposes key information that could help launch an attack against your website, as well as giving real time feedback to those crafting attacks.
Generally I put restrictions in place so that the error details are only displayed in the page if the IP address of the visitor matches the IP address of one of my offices OR if the visitor is currently ‘logged in’ (assuming the project I’m working on has some sort of authentication system).
A Better Way
Additionally, I also have the script send an email to me any time an error is generated – this is a great way of finding out detailed information about errors other users are experiencing. In some cases this has allowed me to fix an error before a user has even had time to report it to me.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>Server Error Example Server 500 Error
We're very sorry but there has been an unexpected error on the website.
<% Set myErrorObject = server.GetLastError() errorHTML = "Error Summary
" & vbCrLf IF myErrorObject.ASPCode <> "" THEN errorHTML = errorHTML & "ASP Code: " & myErrorObject.ASPCode & "
" & vbCrLf IF myErrorObject.Source <> "" THEN errorHTML = errorHTML & "Source: " & myErrorObject.Source & "
" & vbCrLf IF myErrorObject.File <> "" THEN errorHTML = errorHTML & "FileName: " & myErrorObject.File & "
" & vbCrLf IF myErrorObject.Line <> "" THEN errorHTML = errorHTML & "LineNumber: " & myErrorObject.Line & "
" & vbCrLf IF myErrorObject.Description <> "" THEN errorHTML = errorHTML & "Description: " & myErrorObject.Description & "
" & vbCrLf IF myErrorObject.ASPDescription <> "" THEN errorHTML = errorHTML & "ASP Description: " & myErrorObject.ASPDescription & "
" & vbCrLf errorHTML = errorHTML & "Time of error: " & time & " on " & date & "
" IF Request.ServerVariables("REMOTE_ADDR") <> "" THEN errorHTML = errorHTML & "IP Address: " & Request.ServerVariables("REMOTE_ADDR") & "
" & vbCrLf errorHTML = errorHTML & "Query String Contents
" & vbCrLf FOR EACH queryStringObject IN REQUEST.QUERYSTRING errorHTML = errorHTML & "" & queryStringObject & ": " & Request.QueryString(queryStringObject) & "
" & vbCrLf NEXT errorHTML = errorHTML & "Form (Post) Contents
" & vbCrLf FOR EACH formObject IN REQUEST.FORM errorHTML = errorHTML & "" & formObject & ": " & Request.Form(formObject) & "
" & vbCrLf NEXT errorHTML = errorHTML & "Session Variable Contents
" & vbCrLf FOR EACH currentSessionVariable in Session.Contents errorHTML = errorHTML & "" & currentSessionVariable & ": " & Session(currentSessionVariable) & "
" & vbCrLf NEXT 'CALL SENDEMAILFUNCTION ("[email protected]", "[email protected]","Error on Website", errorHTML) 'IF SESSION("myLoginSessionVariable") OR Request.ServerVariables("remote_addr") = "123.123.123.123" THEN RESPONSE.WRITE(errorHTML) %>
Hi can you help me, I have a similar problem, but can not find customErrors files, could you tell me where I find on godaddy
Hey Julio,
The “customerrors” folder in my example (in the path “/sparkly/customerrors/500/default.asp”) is the page I created to handle errors – GoDaddy don’t provide that, it’s something you have to create yourself. To help I have added a simple error handling script I sometimes use to monitor websites but read the comments as there are security considerations!
Bob
Thank you for this!
I needed to use a custom .asp file with redirects for my 404 errors but this wouldn’t work properly with godaddy hosting. They allow you to use custom error pages but it just redirects to the custom file instead of executing it in place.
I was able to modify the web.config in the same way you have for my 404 errors, and that solved the problem.