Hi,
How to get Session values in Global.asax?
My codes:
protected void Application_AuthenticateRequest(object sender, EventArgs e){
try{
if (HttpContext.Current.Session["UserID"]!=null){ // Program error occurs here.// TO DO STH...}
}catch { } // Not logged in does not make.
}
Note: I need to do this: whenever the user touches a page to know the login ID.
Thanks.


Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 23, 2014, 8:10 PM EDT
Hi,
I think you cannot access the session in Application_AuthenticateRequest event because session is not available at this time.
so i think PostAuthenticateRequest event can help you to log the user info.
http://msdn.microsoft.com/en-us/library/system.web.httpapplication.postauthenticaterequest.aspx
hope this will help you.
Ken HRank #2,315 · 610 reputationPosted Apr 24, 2014, 7:38 AM EDT