aspnet / AspNetSessionState

ASP.NET Session State (not for ASP.NET Core)
MIT License
55 stars 43 forks source link

Introduction

SessionStateModule is ASP.NET’s default session-state handler which retrieves session data and writes it to the session-state store. It already operates asynchronously when acquiring the request state, but it doesn’t support async read/write to the session-state store. In the .NET Framework 4.6.2 release, we introduced a new interface named ISessionStateModule to enable this scenario. You can find more details on this blog post.

How to build

  1. Open a VS developer command prompt
  2. Run build.cmd. This will build Nuget package and run all the unit tests.
  3. All the build artifacts will be under aspnetsessionstate\bin\Release\ folder.

How to contribute

Information on contributing to this repo is in the Contributing Guide.

How to use

  1. Update your web.config to remove the old session state module and register the new one:
    <system.webServer>
    <modules>
      <!-- remove the existing Session state module -->
      <remove name="Session" />
      <add name="Session" preCondition="integratedMode,managedHandler" type="Microsoft.AspNet.SessionState.SessionStateModuleAsync, Microsoft.AspNet.SessionState.SessionStateModule, Version=2.0.0.0, Culture=neutral" />
    </modules>
    </system.webServer>
  2. Add one of the new providers to the <sessionState> section of your web.config:
    <sessionState cookieless="false" regenerateExpiredSessionId="true" mode="Custom" customProvider="YourProviderName">
    <providers>
      <add name="YourProviderName" skipKeepAliveWhenUnused="false" [providerOptions] type="Provider, ProviderAssembly, Version=, Culture=neutral, PublicKeyToken=" />
    </providers>
    </sessionState>

    The specific settings available for the new session state module and providers are detailed in their respective doc pages.

Module and Providers contained here

V2.0 Updates: