Session State Compression in ASP.NET 4.0

A new feature to ASP.NET 4.0 is session state compression when you use SQL Server or the ASP.NET State Service. These are the two options available for ASP.NET in a web farm. Because both options involve storing state information outside a web application's worker process, session state has to be serialized before it is sent to remote storage. Depending on how much information a developer saves in session state, the size of the serialized data can grow quite large.

ASP.NET 4.0 introduces a new compression option for both kinds of out-of-process session-state providers. ASP.NET will compress and decompress serialized session state.

To enable this update the sessionState in the web.config file:

<sessionState compressionEnabled="true"
mode="SQLServer"
sqlConnectionString="data source=your-server;
Initial Catalog=aspnetstate;User ID=user;Password=password;
"
allowCustomSqlDatabase="true" />


Will you give this article a +1 ? Thanks in advance


About The Author

Malcolm Sheridan is a Microsoft awarded MVP in ASP.NET and regular presenter at conferences and user groups throughout Australia. Being an ASP.NET Insider, his focus is on web technologies and has been for the past 10 years. He loves working with ASP.NET MVC these days and also loves getting his hands dirty with JavaScript. He also blogs regularly at DotNetCurry.com. Follow him on twitter @malcolmsheridan

No comments: