0

I have a global error handler in Global.asax and am trying to display the exception information in a page called ErrorPage.aspx. I've read Microsoft's page about passing information between asp.net pages (http://msdn.microsoft.com/en-us/library/6c3yckfw.aspx). I don't think any of these will work:

  • QueryString: I'm concerned that the length of the exception will exceed the maximum length of the QueryString.
  • Post Information: The Global.asax page doesn't have any form fields.
  • Session State: Session state is not available in Global.asax
  • Public Values: I think this only works with .aspx pages
  • Control from Source Page: Global.asax can't have asp.net controls.

My current thought is that it would be logical to create an instance of the ErrorPage object and navigate to it (as you could do in a Windows Forms application), but I don't know how to do that or if it is possible in asp.net.

Ultimately, I'm looking for a way to display errors caught by a global error handler in a standard .aspx page. Any suggestions would be helpful.

3
  • Server.GetLastError() might be helpful Jul 11, 2012 at 20:57
  • @MilkyWayJoe, for reasons I don't understand, Server.GetLastError() returns null when called on my error page.
    – Emily
    Jul 12, 2012 at 14:09
  • Maybe this is already being cleared out in Application_Error? Jul 12, 2012 at 14:13

1 Answer 1

1

What I would do:

  1. Log exception information including stack trace in a log file,
  2. Redirect to an ErrorPage with error code (regular http errorcodes + a generic 'unknown error' one + maybe some custom errors that make sense for the application) passed in query string parameter,
  3. Display a predefined message for this error code.

There is little reason to display actual error messages to end users, more detailed error information not withstanding. If you want to display full information for debugging purposes, turn custom errors off in web.config

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.