23rd Nov, 2007

Session data gets lost in Application_Error

The other day I encountered an interesting problem at work where an asp.net application was trying to recursively load an error page when an exception was being thrown. This problem was occurring due to the fact that the Application_Error event handler in global.asax was redirecting to an error page using Response.Redirect. The error page was then trying to access session data which didn’t exist and the Application_Error event was firing again and reloading the error_page recursively.

I discovered that the Session data was getting lost when using Response.Redirect in the Application_Error event. To fix this problem and retain session data I used Server.Transfer and the session data was accessible on the error page.

Have you ever been to Malta? All you need to know is a click away! Malta Travel Guide, Bargain Accommodation in Malta, Malta Hotels

Leave a response

Your response:

Categories