Global.asax and Session State

S

stewartfip

My global.asax file looks something like this:

sub Session_Start()
[some database activity]

session("sessionID") = [value from cmd output param]
end sub

sub Application_PreRequestHandlerExecute()
if session("sessionID") <> 0 then
[do some stuff]
end if
end sub

....which seems to have worked fine up until this weekend. I have a
simple routine that e-mails application errors to me and I've been
HAMMERED suddenly with 'Session state is not available in this context'
on the line that reads 'if session("sessionID") <> 0 then...' which
doesn't make sense because Application_PreRequestHandlerExecute was
supposed to be a safe place to mess around with session variables.

So I'm at a loss in terms of where to begin troubleshooting this
problem. Am I referencing session variables in too simple a manner?
At this point, I'm not clear if this is happening to a given user on
every page, or if it just happens on their first page view and then
things are fine thereafter. I get an error every, oh, three minutes.
So it's happening a lot.

I'll provide more details, just tell me what you need to know. I'm
reasonably new to ASP.Net and am using VB, if that wasn't completely
obvious.
 
G

Guest

I experienced the same issue after updating the IIS properies for my site
from ASP 1.1 to ASP 2.0. I switched it back to 1.1 until I recode around the
issue, and the problem did go away.

I would also like to know why Session is no longer valid at this point in
Global.asax.
 
E

Edwin Knoppert

Afaik everything in Application_ is not related to session.
Unf. i needed as well :)



Jhonda said:
I experienced the same issue after updating the IIS properies for my site
from ASP 1.1 to ASP 2.0. I switched it back to 1.1 until I recode around
the
issue, and the problem did go away.

I would also like to know why Session is no longer valid at this point in
Global.asax.

My global.asax file looks something like this:

sub Session_Start()
[some database activity]

session("sessionID") = [value from cmd output param]
end sub

sub Application_PreRequestHandlerExecute()
if session("sessionID") <> 0 then
[do some stuff]
end if
end sub

....which seems to have worked fine up until this weekend. I have a
simple routine that e-mails application errors to me and I've been
HAMMERED suddenly with 'Session state is not available in this context'
on the line that reads 'if session("sessionID") <> 0 then...' which
doesn't make sense because Application_PreRequestHandlerExecute was
supposed to be a safe place to mess around with session variables.

So I'm at a loss in terms of where to begin troubleshooting this
problem. Am I referencing session variables in too simple a manner?
At this point, I'm not clear if this is happening to a given user on
every page, or if it just happens on their first page view and then
things are fine thereafter. I get an error every, oh, three minutes.
So it's happening a lot.

I'll provide more details, just tell me what you need to know. I'm
reasonably new to ASP.Net and am using VB, if that wasn't completely
obvious.
 

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

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,526
Members
44,997
Latest member
mileyka

Latest Threads

Top