Search code examples
asp.netsession-management

Implementing own Session Management in ASP.NET


What options are there to implement an own session management in ASP.NET?

I just found one older solution about "highjacking" the built-in session management.

Is there a nice way to implement a component which performs all session tasks? How can i include a class which receives the HTTP Request and Response during one request process?

Thanks for your help

Regards Michael


Solution

  • You need two things, implement the IHttpSessionState and a HttpModule. In the HttpModule you hook the applications AcquireRequestState and ReleaseRequestState events.

    In the Web.Config you need to remove the default session module and include your own.

    The System.We.SessionState namespace has a number of other classes that you can uses in your implementation if you desire and/or you can use for a reference pattern.