473,395 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

cannot access Session Variables

in the Global.asax Application_EndRequest prodecure
the application do something and it works normally
but when i try to use session
it gives errors "Object reference not set to an instance of an object." i
cannot access a Session variable...

System.Web.HttpContext.Current.Session["CurrentUserID"] = 5;
a = (int)System.Web.HttpContext.Current.Session["CurrentUserID"];

this code doesnt work at the Application_EndRequest

Does anybody tell me why?

Nov 18 '05 #1
3 4898

"Kaya" <cg*****@luckyeye.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
in the Global.asax Application_EndRequest prodecure
the application do something and it works normally
but when i try to use session
it gives errors "Object reference not set to an instance of an object." i
cannot access a Session variable...

System.Web.HttpContext.Current.Session["CurrentUserID"] = 5;
a = (int)System.Web.HttpContext.Current.Session["CurrentUserID"];

this code doesnt work at the Application_EndRequest

Does anybody tell me why?


It probably isn't the Session that is null, but HttpContext.Current.
Apparently there is no HttpContext anymore when the EndRequest fires.

Hans Kesting
Nov 18 '05 #2
ok is there any way to access Session variables
at the Application_EndRequest

"Kaya" <cg*****@luckyeye.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
in the Global.asax Application_EndRequest prodecure
the application do something and it works normally
but when i try to use session
it gives errors "Object reference not set to an instance of an object." i
cannot access a Session variable...

System.Web.HttpContext.Current.Session["CurrentUserID"] = 5;
a = (int)System.Web.HttpContext.Current.Session["CurrentUserID"];

this code doesnt work at the Application_EndRequest

Does anybody tell me why?

Nov 18 '05 #3
I do not believe you can as the Session has ended before the Application_End
event fires. The only thing I can think of is to move your code from
Application_End to Session_End.

Jeff

"Kaya" <cg*****@luckyeye.com> wrote in message
news:uI**************@TK2MSFTNGP12.phx.gbl...
ok is there any way to access Session variables
at the Application_EndRequest

"Kaya" <cg*****@luckyeye.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
in the Global.asax Application_EndRequest prodecure
the application do something and it works normally
but when i try to use session
it gives errors "Object reference not set to an instance of an object." i cannot access a Session variable...

System.Web.HttpContext.Current.Session["CurrentUserID"] = 5;
a = (int)System.Web.HttpContext.Current.Session["CurrentUserID"];

this code doesnt work at the Application_EndRequest

Does anybody tell me why?


Nov 18 '05 #4

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

Similar topics

2
by: mr_burns | last post by:
Hi, i am getting the following errors when running my php script: Warning: Cannot send session cookie - headers already sent by (output started at ...
3
by: Michael J. Astrauskas | last post by:
I have a site where a user logs in and a session variable I created is used to keep track of the fact that the user is logged in. This various pages query a MySQL database to get information...
0
by: Jack | last post by:
Hi, I have the following problem. I have a main data entry form which has a link to a detailed data entry form. The value of the link in the main form is the sum total of all the line items...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
0
by: cdginc | last post by:
Hello, I am trying to implement a sales cart application that uses VBScript and writes the data to an Access database. This is a prepackage software that I am trying to customize for my needs. ...
0
by: totierne | last post by:
comp.databases.ms-access, I want to know how to use Oracle views with session variables in Access. The parameterised views in access, are migrated to views with per session variables. The...
4
by: Primo | last post by:
Hi, This problem has been frustrating me for days and I hope you experts can help me out. I am trying to run a command, which I would normally run from the command line, from within my C#...
0
by: bharathreddy | last post by:
Here I will given an example on how to access the session, application and querystring variables in an .cs class file. Using System.Web.HttpContext class. 1) For accesing session variables :...
1
by: chowdary | last post by:
hi, when the user clicks the logout.php the session variables are destroying. my doubt is when the user clicking back, again they are entering into the pages. how to check whether session...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.