Re: Accessing SessionState in Application_Error
- From: "Nemisis" <darrens2005@xxxxxxxxxxx>
- Date: 13 Mar 2007 08:10:29 -0700
If the error is occurring there, then the problem is that you don't
have a valid session object. This is born out by the fact that you've
tried twice to write two different variables to the session, and both
of them raise the same exception.
So the next question I have for you is this: What is the exception
that is putting you in this exception handler in the first place?
Whatever it is, it's apparently occurring before you have a valid
session, or it's disconnecting the user from their session. I'd look
there.
Without a valid session, you won't be able to cache the exception
information in it. To prevent the NullReferenceException, wrap the
offending statement in a conditional, as follows (assuming VB.NET):
If Not HttpContext.Current.Session Is Nothing Then
HttpContext.Current.Session.Add("LastException", Exception)
End If
Hope this helps!
Mike
In order to get this error, i am trying to navigate to a page that
doesnt exist on my site ie. Home4.aspx. This causes the
application_Error sub to be called, but the session is empty/null. If
i create a standard page, and write Throw New Exception(), again, the
application_error code is called, but the session IS VALID, and i do
not get a NullReferenceException.
Why do you get a nullreferenceexception on a 404 error? Is it because
the page is not apart of your application, thus the session wont exist?
.
- Follow-Ups:
- Re: Accessing SessionState in Application_Error
- From: Mike Hofer
- Re: Accessing SessionState in Application_Error
- References:
- Accessing SessionState in Application_Error
- From: Nemisis
- Re: Accessing SessionState in Application_Error
- From: Mike Hofer
- Re: Accessing SessionState in Application_Error
- From: Nemisis
- Re: Accessing SessionState in Application_Error
- From: Mike Hofer
- Accessing SessionState in Application_Error
- Prev by Date: Re: asp.net 1.1 generates spurious whitespace
- Next by Date: Re: Is Nothing problem
- Previous by thread: Re: Accessing SessionState in Application_Error
- Next by thread: Re: Accessing SessionState in Application_Error
- Index(es):
Relevant Pages
|