Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top