Storing aspnet session state in sql server07/27/2010
In a single server configuration you might want to use a session state server in order to facilitate restarting Internet Information Services (IIS) without killing all active Web site sessions. In a server farm environment you should use an out-of-memory medium for storing asp.net session state in order to avoid use of sticky routing in the load balancer.
Here's the command you need to execute from the command line on the server where MS SQL Server is installed. The command installs the necessary tables and stored procedures which enable session state management.
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727> aspnet_regsql.exe -ssadd -sstype c -d [YOURDATABASENAME] -E
In your web application, all you need to do to switch from in-memory session management to SQL server session management is add the following node into the
Note: compressionEnabled="true" attribute is new to .NET Framework v4.x. According to the ASP.NET 4 and Visual Studio 2010 Web Development Overview whitepaper, the attribute enables shrinking of the serialized session state before writing it to the database. This improves application performance.