benners70
asked on
ASP - Send custom errors to error 500 page
When an error occurs in my ASP page scripts the visitor gets set to a customised error 500 page which displays the standard errors properties from Server.GetLastError()
I would like to be able to send through other useful debugging information such as
Request.servervariables("A LL_HTTP") and perhaps a SQL string if available.
The code below is my attempt to pass custom variables to my custom 500.asp page. It redirects ok but it not working right as it nolonger displays the error properties of Server.GetLastError()
Any ideas on how to achieve this?
Thank you. Paul.
I would like to be able to send through other useful debugging information such as
Request.servervariables("A
The code below is my attempt to pass custom variables to my custom 500.asp page. It redirects ok but it not working right as it nolonger displays the error properties of Server.GetLastError()
Any ideas on how to achieve this?
Thank you. Paul.
<%@Language="VBSCRIPT"%>
<% On Error Resume Next %>
<html>
<head>
<title>Bad Page 1</title>
</head>
<body>
<% Response.Write 1/0 %>
</body>
</html>
<%
If Err.number <> 0 then
Response.Clear
errorString = Request.servervariables("ALL_HTTP")
response.Redirect("500.asp?customerrors=" & errorString)
End If
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try this.
http://www.devguru.com/technologies/ASP/quickref/server_getlasterror.html
http://www.devguru.com/technologies/ASP/quickref/server_getlasterror.html
<%
Dim objErrorInfo
Set objErrorInfo = Server.GetLastError
Response.Write("ASPCode = " & objErrorInfo.ASPCode)
Response.Write("ASPDescription = " & objErrorInfo.ASPDescription)
Response.Write("Category = " & objErrorInfo.Category)
Response.Write("Column = " & objErrorInfo.Column)
Response.Write("Description = " & objErrorInfo.Description)
Response.Write("File = " & objErrorInfo.File)
Response.Write("Line = " & objErrorInfo.Line)
Response.Write("Number = " & objErrorInfo.Number)
Response.Write("Source = " & objErrorInfo.Source)
%>
ASKER
Hi Carrzkiss
From the info you've given, it seems it's not possible to either:
a) pass variables from a page with an error through to a custom IIS error500 page
b) access Server.GetLastError anywhere other that in the IIS error500 page
In laymans terms for the ISS error500 page to load the page with an error can't load and for a page with an error to resume next and load would mean the ISS error500 page cannot be accessed.
If I'm incorrect in these conclusions I'd be pleased to here.
However, by accessing various ServerVariables in my custom error 500 page I am able to debug most errors.
Thanks
From the info you've given, it seems it's not possible to either:
a) pass variables from a page with an error through to a custom IIS error500 page
b) access Server.GetLastError anywhere other that in the IIS error500 page
In laymans terms for the ISS error500 page to load the page with an error can't load and for a page with an error to resume next and load would mean the ISS error500 page cannot be accessed.
If I'm incorrect in these conclusions I'd be pleased to here.
However, by accessing various ServerVariables in my custom error 500 page I am able to debug most errors.
Thanks
to bad we could not do what you really wanted.
So, the [B] is ok, considering that it was not what you was really needing.
Have a good one.
Carrzkiss
So, the [B] is ok, considering that it was not what you was really needing.
Have a good one.
Carrzkiss
ASKER
I wasn't immediately sure what you have provided but I replaced my custom error 500 page with your code and it worked, but I'm not sure it's quite what I was after.
I think key question I have is can I pass variables used on the page with an error through to the IIS error page for display and still get access to all the properties of Server.GetLastError()?
I can of course redirect to another error handling page if an error is found and pass variables that exist on the page that had the error (see code snippet). But if I do this, I don't seem to be able to access to the properties of Server.GetLastError() unless I go through to the IIS error 500 page.
Open in new window