SQL Server Session

Configuration for SQL Server Session Mode  

add

   <sessionState mode="SQLServer" sqlConnectionString="data source=.;  user id=sa;password=sa"/>

 

In SQL Server  Session mode, we are storing session data in a SQL Server, so we need to first provide the database connection string in web.config . sqlConnectionString attribute is used to provide the connection string in web.config.  

 

After setup the connection string we need to configure the SQL Server. I am explaining how to configure your your SQL server using aspnet_regsql command.

Step 1: From Command prompt, Go to your Framework Version Directory

E.g :c:\windows\microsoft.net\framework\<version>.

Step 2 : Run aspnet_regsql command with following parameters

C:\WINDOWS\Microsoft.NET\Framework\V2.0.50727>aspnet_regsql -S localhost -U sa -P sa -ssadd -sstype p

Have a look on the parameter and there uses

Parameters   Description
-ssadd Add support for SQLServer mode session state.
-sstype p P is stands for Persisted. Its persist the session data on server
-S Specify Server Name
-U Specify User Name
-P Specify Password

that's all .

Step 3 : Open SQL Server Management Studio, Check, A new database ASPState has been created  and there should be two tables, 

  • ASPStateTempApplications 
  • ASPStateTempSessions 

 

原文地址:https://www.cnblogs.com/greencolor/p/1668830.html