This method not only stores session information outside the process, but also stores session information in other server processes. In this case, you not only need to change the mode Value to StateServer, but also need to configure the corresponding parameters in stateConnectionString. For example, if you want to store the session in the process of a computer whose ip address is 192.168.0.2, you need to set it to stateConnectionString = "tcpip = 192.168.0.2: 42424 ". Of course, do not forget to install. NET Framework on the computer 192.168.0.2 and start the asp. NET State Services Service.
Store server session information in SQL server
First, let's make some preparations. Start the SQL server and SQL server proxy services. Execute a script file named InstallSqlState. SQL in SQL server. This script file will create a database in SQL server for storing session information and an SQL server proxy job for maintaining the session information database. You can find the file in the following path:
[System drive] \ winnt \ Microsoft. NET \ Framework \ [version] \
Then open the query analyzer, connect to the SQL server, open the file and execute it. Wait a moment and the database and job will be created. In this case, you can open the Enterprise Manager and see a new database called ASPState. However, this database only contains some stored procedures and does not use user tables. In fact, session information is stored in the ASPStateTempSessions table of the tempdb database, and the other ASPStateTempApplications table stores the application Object Information in asp. These two tables are also created by the script just now. In addition, you can view "manage"> "SQL server proxy"> "job" and find another job called ASPState_Job_DeleteExpiredSessions. This job actually deletes expired session information from the ASPStateTempSessions table every minute.
Then, we return to the Web. config file and change the mode Value to SQLServer. Note: You must also modify the sqlConnectionString value in the following format:
SqlConnectionString = "data source = localhost; Integrated Security = SSPI;" data source refers to the IP address of the SQL server. If SQL server and IIS are a server, write 127.0.0.1. Integrated Security = SSPI means to use Windows Integrated Identity Authentication, so that accessing the database will use asp.. NET identity, through this configuration, you can obtain better security than the SQL server authentication method using userid = sa; password = password. Of course, if SQL server runs on another computer, you may need to maintain consistency between the two sides through Active Directory domains.
Similarly, let's do a test. Add the session information to SessionState. aspx and you will find that the session information already exists in SQL server. Even if you restart the computer, the session information will not be lost. Now, you have fully seen what session information looks like and what it is stored in SQL server. What you can do depends on your performance.
Summary
Iii. asp.net general settings on form Authentication
Asp.net general settings on form authentication:
1: Add form authentication in web. config;
<