Method one. Web. config changes the mode of sessionstate to "InProc" (default)
Inside the Web. config:
<sessionstate mode= "InProc" stateconnectionstring= "tcpip=127.0.0.1:42424" sqlconnectionstring= "Data source= 127.0.0.1;user id=sa;password= "cookieless=" false "timeout="/>
If it is stateserver, it means that the State service is in the remote server mode, you need to set the server string and password parameters.
Method Two: Enable the "ASP. NET State Service" in Windows services
Introduction to the session model
What is the session? In simple terms, the server gives the client a number. When a WWW server is running, there may be a number of users browsing the Web site that is being shipped on this server. When each user establishes a connection to this WWW server for the first time, he establishes a session with the server, and the server automatically assigns it a SessionID to identify the user's unique identity. This SessionID is a 24-character string randomly generated by the WWW server, and we'll see what it looks like in the experiment below.
The only SessionID is of great practical significance. When a user submits a form, the browser automatically attaches the user's SessionID to the HTTP header information (this is the browser's automatic function, which the user will not perceive), and when the server finishes processing the form, the result is returned to the user of SessionID. Imagine, if there is no SessionID, when two users register at the same time, how the server can know exactly which user submitted which form.
Session configuration information in the Web. config file
After opening the configuration file for an application, Web. config, we will find the following paragraph:
<sessionstate
Mode= "InProc"
Stateconnectionstring= "tcpip=127.0.0.1:42424"
sqlconnectionstring= "Data source=127.0.0.1; Trusted_connection=yes "
Cookieless= "false"
Timeout= "20"
/>
Where mode sets the session information to where, OFF is set to not use the session function; InProc is set to store the session in process, is the ASP storage mode, which is the default value; The StateServer is set to store the session in a separate state service; SQL Server settings stores the session in a
Session state requests cannot be made to the session-state server. Make sure that the ASP. NET state Service (ASP.