Easiest way to get page name from error routine?

G

Guest

Hello all

When I jump to a generic error page, is there an easy way to know which page generated the error

I've got a catch-all error handler in Application_Error in global.asax. From there, I want to format a query string, then pass that to ErrorPage.aspx to display the formatted error. I can get server.GetLastError and pass system.exception.message, but I'd also like to pass the url of the offending page that raised the error, but am not seeing how to easily get this. I know that on each page I could store the url in session in case the error page needs it sometime, but it seems like there's an easier way to just get the url of the "caller" to the error page

Any thoughts are appreciated

Thanks

Bill Borg
 
T

Tommy

Try getting the stack trace from the inner exception.

Sample:
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Fires when an error occurs
Dim myError As Exception = Server.GetLastError
If Not myError.InnerException Is Nothing Then
Dim stackTrace As String =
myError.InnerException.StackTrace()
End If

Server.ClearError

End Sub

Tommy,

Bill Borg said:
Hello all,

When I jump to a generic error page, is there an easy way to know which page generated the error?

I've got a catch-all error handler in Application_Error in
global.asax. From there, I want to format a query string, then pass
that to ErrorPage.aspx to display the formatted error. I can get
server.GetLastError and pass system.exception.message, but I'd also
like to pass the url of the offending page that raised the error, but
am not seeing how to easily get this. I know that on each page I
could store the url in session in case the error page needs it
sometime, but it seems like there's an easier way to just get the url
of the "caller" to the error page.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top