How can I pass some data from a Global.asax event handler to a custom error page in ASP.NET without using Server.Transfer or some redirect?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming you’re catching unhandled exceptions in global.asax, I don’t think you can. You’re no longer in anyone’s session at that point, so you’ve lost just about all connection with the error, other than the exception itself.
You might try catching unhandled exceptions in each page, by adding a handler for the Page_Error event. You can centralize some of that by having each page subclass your own application “page base” class instead of System.Web.UI.Page, and make sure that your “page base” class inherits from System.Web.UI.Page. Then have your page base class handle Page_Error. But you won’t be in page-specific code at that point, so you’ll still have to figure out a method for passing data to that custom error page.