tonto said:
Two questions.
- How can I change this in the future? I just logged into my CP and it does not show a custom error.
- Do I have to go through a ticket every time I need to set up a new one or edit this one?
It would be under "Web Services" for each domain.
FWIW, I route each error to /error.asp (select the "URL" option)
IIS attaches a querystring to the url formatted as 999;xxxxxxxx where 999 is the 3 digit error code and xxx is the URI that tossed the error. error.asp examines the query string to determine the error that called it and then does stuff based upon the error.
The stripped down version of error.asp is here...
Code:
<%
'This script...
' 1. Extracts the error code and error page from the query string passed by IIS.
' 2. Displays the error message.
' 3. Uses AspEmail to email error notification to whomever.
'You will need to change...
' 1. strDomain in "GENERAL VARIABLES"
' 2. StrReturnAddress and StrToAddress in "MAIL VARIABLES"
' 3. href for the stylesheet in the html area
' 4. Any email or html particulars you want
' -------------------------------------------------------------------------------
'GENERAL VARIABLES
Dim strDomain
strDomain ="example.com"
' ERROR VARIABLES
dim arrErrInfo
Dim strErrorCode
Dim strErrorMessage
Dim strErrorPage
' GET ERROR CODE AND PAGE
On Error Resume Next
arrErrInfo = Split(Request.ServerVariables("QUERY_STRING"),";")
strErrorCode = Trim(arrErrInfo(0))
strErrorPage = Trim(arrErrInfo(1))
Select Case strErrorCode
Case "400"
strErrorMessage = "Bad Request - Resubmitting the request may correct the problem."
Case "401"
strErrorMessage = "Authorization Required"
Case "403"
strErrorMessage = "Forbidden Resource"
Case "404"
strErrorMessage = "Page/Resource Not Found"
Case "405"
strErrorMessage = "Method Not Allowed"
Case "500"
strErrorMessage = "An Internal Server Error has occurred"
Case "501"
strErrorMessage = "Method Not Implemented"
Case ELSE
strErrorMessage = "An Unknown Error Has Occurred"
End Select
' -------------------------------------------------------------------------------
' MAIL VARIABLES
Dim StrReturnAddress
StrReturnAddress = "postmaster@" & strDomain
Dim strMailServer
strMailServer = "localhost"
Dim StrSenderName
StrSenderName = strDomain & " Error Page"
Dim StrToAddress
StrToAddress = "me@" & strDomain
Dim strVariable
Dim StrBody
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title><%=strErrorCode%> Error at <%=strDomain%></title>
<link rel="stylesheet" type="text/css" href="/site.css">
</head>
<body>
<div>
<h1><%=strDomain%></h1>
</div>
<div align="center">
<h3>An Error Has Occurred</h3>
<p>Error: <%=strErrorCode%> - <%=strErrorMessage%></p>
<br/>
<p>Requested Page: <%=strErrorPage%></p>
</div>
<div align="center" style="margin-top:30px;">This error has been logged.</div>
</body>
</html>
<%
' SEND THE EMAIL
StrBody = "Error at " & strDomain & vbCRLF
StrBody = strBody & strErrorCode & " - " & strErrorMessage & vbCRLF
StrBody = strBody & "Page = " & strErrorPage & vbCRLF
Dim objAspEmail
Set objAspEmail = Server.CreateObject("Persits.MailSender")
objAspEmail.Host = strMailServer
objAspEmail.From = StrReturnAddress
objAspEmail.MailFrom = StrReturnAddress
objAspEmail.FromName = StrSenderName
objAspEmail.AddAddress StrToAddress
objAspEmail.AddReplyTo StrToAddress
objAspEmail.Subject = strErrorCode & " Error at " & strDomain
objAspEmail.Body = StrBody
On Error Resume Next
objAspEmail.Send
Set objAspEmail = Nothing
%>
error.asp is in the root directory. I usually use Instr to check strErrorPage for strings common to bad or moved urls and suggest alternate urls.
ONE BIG CAVEAT... for some reason, Jodohost doesn't handle favicon.ico as an image error. Firefox tosses a 404 error if it can't find favicon.ico and Jodo handles it as a page error. You'll get to your requested page when the error page starts to be written, but if you email before trying to display the error page, you'll also get an email for the favicon 404.
I work around it by putting the asp code for mailing after the html code for displaying.
EDIT: The above error handler will return an error code of "200 - OK". If you want to return the actual error code to the original requestor, add the following line after the "End Select" statement...
Response.Status = strErrorCode & " " & strErrorMessage