Session is lost during error handling

O

Oscar Thornell

Hi,

I have an ASP.NET page that generates an Exception...
The Exception is not caught in the executing method...so it propagates
to..the Page_Error event handling method..
In that method the Exception is handled by the client exception
policy...basically it logs the information coming from the business layer...
We then create a custom message object that contains user/context specific
information and adds that to the Session object..
Since I don´t call Server.ClearError() the Exception propagates
further...and is handled by the applications Error page...

In the Error page I would like to retrive the custom error object from the
Session but the object is not there...
Only if I make a specific Response.Redirect() can I retrive the
session...i.e. not using ASP.NETs error handling/propagating.

Why am I losing this information? What is going on inside ASP.NET with the
session during error handling?

Regards
/Oscar
 
T

Teemu Keiski

Hello,

from here:

http://forums.asp.net/7504/ShowPost.aspx

Q: Will my session state be saved when my page hit an error?
A: If you're using StateServer or SQLServer mode, for data integrity reason
session state module will not save any changes to session state if there is
an error. To work around this, you can call Server.ClearError in your
exception handler.
For InProc mode, changes are made directly to the in-memory objects and so
whatever changes you've made so far will stay in the memory. However, if
it's a new session, ASP.NET will not insert your session state into the
internal table, and thus your session state will NOT be saved, unless you
call Server.ClearError in your exception handler.
 

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