469,609 Members | 1,831 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

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 4706

"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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Michael J. Astrauskas | last post: by
1 post views Thread by chowdary | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.