The default ASP.NET SessionStateModule is already partly asynchronous; it reads the request state asynchronous, but it doesn’t support async when reading/writing to the session store. In the .NET Framework 4.6.2 release, Microsoft changed this by introducting a new interface named ISessionStateModule.
Thanks to the async SessionState module it becomes possible to access the session storage providers(SQL Server, Redis,…) asynchronously. Async I/O operation helps release the thread more quickly than synchronous I/O operation, and ASP.NET can handle other requests.
Here are the required steps to start using this module:
- Change your application to target .NET Framework 4.6.2
- Download and install the Microsoft.AspNet.SessionState.SessionStateModule NuGet package. This will replace the default session state provider by the new async one.
- Download an async session state provider from NuGet. At the moment of writing I only could find an implementation for SQL Server, but the hope is that other will follow soon.
The introduction of this module will help in improving the performance of your ASP.NET applications.