global.asax
-
i want to use session variable in global.asax when using folowing code. protected void Application_AuthenticateRequest(Object sender, EventArgs e) { if (Session["role"] != null) { //strRole = Session["role"].ToString(); } } it gives error.>> Session state is not available in this context. Please solve my problem as soon as possible. Thanking u ajai
-
i want to use session variable in global.asax when using folowing code. protected void Application_AuthenticateRequest(Object sender, EventArgs e) { if (Session["role"] != null) { //strRole = Session["role"].ToString(); } } it gives error.>> Session state is not available in this context. Please solve my problem as soon as possible. Thanking u ajai
ajau wrote:
Session state is not available in this context.
The error message is very clear enough. You can't use session in this event as it's not instantiated.
Application_AuthenticateRequest
is in the early stage of ASP.NET page life cycle.AcquireRequestState
is the event where session will be created. So choose any event that fires afterAcquireRequestState
.All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions