When's the earliest i can access some Session data in global.asax?
I always believed Application_AcquireRequestState
was the first event in Global.asax that could access the current session. It's definitely not Application_BeginRequest
.
MSDN casually mentions that the session state is acquired during Application_PostAcquireRequestState event. I wish it was restated at the Life Cycle Overview page.
The latest you can access session state is in Application_PostRequestHandlerExecute, as it is saved by SessionStateModule during the next event Application_ReleaseRequestState.
You need to use BeginRequest
(http://msdn.microsoft.com/en-us/library/system.web.httpapplication.beginrequest.aspx) as it is the first event fired on the HttpApplication
object (which the Global.asax inherits).
You'll see more about the ASP.NET Application Lifecycle here - http://msdn.microsoft.com/en-us/library/ms178473.aspx (this is for IIS 5 & IIS 6).