SQL Server mode to store session state in ASP.NET

SQL server mode ensures that session state is preserved if the web application is restarted and also makes session state available to multiple web servers in a web farm. In this article I will give you a step-by-step guide on how to use SQL server mode to store session state in your ASP applications.

Getting Started

To configure your ASP application with SQL Server mode to store session, you must edit the web.config file. It is important that the database you are using, is installed on SQL Server.

  • Set the mode attribute of the sessionState element to SQLServer.
  • Set the sqlConnectionString attribute to a connection string for your SQL Server database.

You can set the SQL Server Mode in the Web.Config file of you application like this:


   <sessionState mode="SQLServer"
     sqlConnectionString="Integrated Security=SSPI;data
       source=SampleSqlServer;" />


code sql server mode state server in asp apps arvixeObjects stored in session state must be serializable if the mode is set to SQLServer.

In conclusion SQL Server Mode offers lower performance than StateServer but offers higher integrity with the data and reporting.

This concludes SQL Server mode to store session state in ASP.NET.

Looking for quality Windows Hosting? Look no further than Arvixe Web Hosting!

Happy Hosting!

Rodolfo Hernandez

Tags: , , , , , , , , , , , , , , , , , | Posted under ASP .NET 4.0 | RSS 2.0

Author Spotlight

Rodolfo Hernandez

I like photography and reading books. Currently working for Arvixe as Elgg Community Liaison. Elgg Security Expert Web Security Expert CEO of UDP SW Social Web

Leave a Reply

Your email address will not be published. Required fields are marked *