Store Session (asp.net) in SQL Server

If we want to store sessions in SQL Server, in which table are sessions stored?

To implement session state management in ASP.NET SQL Server mode, you must modify the item of your Web.config application file as follows:

1. Set the mode attribute of the element on SQLServer to indicate that session state is stored in SQL Server.

2.Set the sqlConnectionString attribute to specify the connection string for SQL Server. For instance:

sqlConnectionString="data source=MySQLServer;user id=<username>;password=<strongpassword>" 

Note. The user must have permission to perform this operation in the database.

The modified item should look like this:

  <sessionState mode="SQLServer" sqlConnectionString="data source=127.0.0.1;user id=<username>;password=<strongpassword>" cookieless="false" timeout="20" /> 

The question is that there is a specific session storage table?

Saving a session in SQL Server is an undefined concept.

Thanks.

+4
source share
3 answers

First you must run the ASP.NET SQL Server logging tool . The tool will create appropriate session state tables.

+4
source

To use SQLServer mode, you must first ensure that the ASP.NET session state database is installed on SQL Server. You can install the ASP.NET session state database using the Aspnet_regsql.exe tool. Aspnet_regsql.exe is located at% windir% \ Microsoft.NET \ Framework \ v4.0.30319 (32-bit .net framework 4 system)

Follow the link below to learn how to add a session table. How to configure SQL Server to store session state

+3
source

Other answers are true that you should use the Aspnet_regsql.exe tool to create a session database for you. But out of interest, once this is done, you can find all the sessions stored in the temporary topic table.

For example, my session database is called ASPState , and the table of interest is called ASPStateTempSessions . ASP.NET calls stored procedures to manage the sessions in this table.

+1
source

All Articles