The following steps are required to save a Session to SQL Server:
1. First, you must create a database that saves sessiondata and use aspnet_regsql.exe as a command. The specific command is
C: \ WINDOWS \ Microsoft. NET \ Framework \ v2.0.50727> aspnet_regsql.exe-ssadd-sstype c
-D sd-E
This command adds an sd database to save session data in windows Authentication mode.
2. Modify the SessionState node in the ASP. NET web. config file, which is located under <system. web>.
Copy codeThe Code is as follows:
<SessionState mode = "SQLServer" allowCustomSqlDatabase = "true"
SqlConnectionString = "server =.; uid = sa; password =; initial catalog = sd"
Cookieless = "false"
Timeout = "20">
</SessionState>
In this way, Session data is stored in the database instead of being dependent on the IIS process. You can open the sd database with two tables: ASPStateTempSessions and ASPStateTempApplications.