473,670 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Global.asax and Session State

My global.asax file looks something like this:

sub Session_Start()
[some database activity]

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

sub Application_Pre RequestHandlerE xecute()
if session("sessio nID") <> 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("sessio nID") <> 0 then...' which
doesn't make sense because Application_Pre RequestHandlerE xecute 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.

Nov 19 '05 #1
2 7826
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.

"st********@yah oo.com" wrote:
My global.asax file looks something like this:

sub Session_Start()
[some database activity]

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

sub Application_Pre RequestHandlerE xecute()
if session("sessio nID") <> 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("sessio nID") <> 0 then...' which
doesn't make sense because Application_Pre RequestHandlerE xecute 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.

Dec 9 '05 #2
Afaik everything in Application_ is not related to session.
Unf. i needed as well :)

"Jhonda" <Jh****@discuss ions.microsoft. com> schreef in bericht
news:47******** *************** ***********@mic rosoft.com...
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.

"st********@yah oo.com" wrote:
My global.asax file looks something like this:

sub Session_Start()
[some database activity]

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

sub Application_Pre RequestHandlerE xecute()
if session("sessio nID") <> 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("sessio nID") <> 0 then...' which
doesn't make sense because Application_Pre RequestHandlerE xecute 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.

Dec 9 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
515
by: Phil Lamey | last post by:
Hi All, I have the following code but for some reason I cannot get the Session_OnEnd event to fire. I am trying to limit the amount of connections a browser session can have. Where the application is a virtual directory. Any ideas? ------------
4
4664
by: Arjen | last post by:
Hi, I load my website settings inside the global.asax file. For this I have to use the context, to get the roles from the current browsing client. The problem is that there is no context at that time. (no reference) When I add these code lines (from global.asax) inside an aspx file, then it works. Because there is a context.
5
3934
by: WJ | last post by:
I am attempting to use the Global.Asax to store my user's configuration. Here is the concept: 1. User logs on into the site using Form Authentication. 2. I capture the user Credential, verify it and then assign this Logon ID (user) a so called User's serverside cookie. 3. My system is configured to accept 1,024 concurrent users, this means that my Global.Asax will host no more than 1,024 Logon IDs and their associated cookies/variables....
2
5201
by: Nathan Sokalski | last post by:
I would like to access variables and functions that I declare in the Global.asax.vb file. However, I am having trouble doing that. What does the declaration have to look like in the Global.asax.vb file, and what would I do to access it? (I am using VB.NET for my code) Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
3
3734
by: kingski | last post by:
I have a web site created with ASP.NET 1.1. availability Global.asax: protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e)
1
1472
by: GaryDean | last post by:
I notice that the global.asax in v2 is inline. because of this I can't say Session = conn; The compiler will accept it but at runtime the exception says "Session State is not available in this context". Is this a downgrade feature from 1.1? -- Regards,
3
3457
by: kurt sune | last post by:
I have a generic errorhandler in global.asax. (in Application_Error) I need to transfer an error string from global asax to a generic error page. So I try: this code with the thought of picking up the string from session an Error.aspx. 1 Dim errorString As String = "the whole error string" 2 Try
3
2881
by: thomson | last post by:
Hi All, i do have an website with the URL http://localhost/application/ASEAN-ANZ, Once i hit the application, it goes to the Global.asax. but after that if i tried to change the URL http://localhost/application/en-US, the global.asax is not fired.
4
7637
by: damiensawyer | last post by:
Hi, I have the following situation. If a user browses to http://domain/somemiscURL.aspx without going through the front door I need to catch the request, forward them to a login page and then, on completion, send them to the original page that they requested. My 'plan' was to do the following. 1/ Catch every request and test if it's "logged in" (determined by existence of an object help in the Session
0
8471
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8903
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8815
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8592
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8661
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5686
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4393
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2802
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1795
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.