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.
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:
<configuration> <system.web> <sessionState mode="SQLServer" sqlConnectionString="Integrated Security=SSPI;data source=SampleSqlServer;" /> </system.web> </configuration>
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.