This post explains about Shrinking session state in ASP.NET 4.0
ASP.NET Provides two options for storing session state for web applications.
1. Out of process session state
2. MS SQL server session state
In both the options session-state providers stores the data out side the web application worker process. Session state has to be serialized before it sends it to the external storage.
ASP.NET 4.0 introduces a new compression option for both out-of-process session state providers. We can set the compressionEnabled option in configuration file to true. ASP.NET will compress the session state by using the .NET Framework System.IO.Compression.GZipStream class.
We can configure the session state as follows
<sessionState mode="SqlServer" sqlConnectionString="data source=dbserver;Initial Catalog=aspnetstate" allowCustomSqlDatabase="true" compressionEnabled="true" />
Advantage: With this addition of attribute to web.config file there is substantial reduction in the size of serialized session-state data.
Share this post : |