Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is session state initialized in the ASP.NET pipeline

I have an IHTTPModule with an event handler for AuthorizeRequest. I would like to access the Session object but it is not yet initialized. Which event should I subscribe to in order to have the session object available as early as possible in the pipeline?

like image 248
esevelos Avatar asked Aug 29 '11 10:08

esevelos


People also ask

Where is session data stored in ASP.NET by default?

By default, ASP.NET will store session information in memory inside of the worker process (InProc), typically w3wp.exe . There are other modes for storing session, such as Out of Proc and a SQL Server.

What is session state in ASP NET MVC?

Session state is an ASP.NET Core scenario for storage of user data while the user browses a web app. Session state uses a store maintained by the app to persist data across requests from a client.

What is session state in ASP.NET c# with example?

In ASP.NET session is a state that is used to store and retrieve values of a user. It helps to identify requests from the same browser during a time period (session). It is used to store value for the particular time session. By default, ASP.NET session state is enabled for all ASP.NET applications.


1 Answers

You needd HttpApplication.PostAcquireRequestState event - http://msdn.microsoft.com/en-us/library/system.web.httpapplication.postacquirerequeststate.aspx. Also there is a HttpApplication.AcquireRequestState event. Don't forget to check if your handler implements IRequiresSessionState or IReadOnlySessionState, otherwise it will throw an exception.

like image 119
Vasea Avatar answered Oct 06 '22 17:10

Vasea