Loading ...

Session State Compression in ASP.NET 4.0 | CodeAsp.Net

Session State Compression in ASP.NET 4.0

 /5
0 (0votes)

Introduction

As we know that there are two options available for session state management in ASP.NET; In-Process and Out-of-Process. In-Process option has one mode InProc. In InProc mode session is stored as an in memory object in web server (aspnet_wp.exe) in same machine. Out-of-Process has two modes State Server and SQL Server. In State Server mode session is also stored as an in memory object but in different process i.e. in aspnet_state.exe. State Server can be configured on different machine. In SQL Server mode, session is stored in SQL Server. Again it may be on different machine. Data to be stored in session must be serialized in Out-of-Process option and it is optional in In-Process option.


But data to be serialized in Out-of-Process option may be large enough depending on how much information going to save in session. But it affects server performance. To solve this ASP.NET 4.0 introduces a new compression option for out-of-process options. ASP.NET will compress and decompress serialized session state.

Enabling Session Compression


You can enable session compression as -

 

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

 

Conclusion

So this is a great feature provided in ASP.NET 4.0. It'll increase server performance. Hope this help.

Comments (no comments yet)

Top Posts