ASP. NET provides five session status options:
Inproc
StateServer
Sqlserver
Custom
Off
1. inproc
Inproc.exe supports saving session Status in the process, while the session status is saved in the w3wp.exe workflow. This means that the session status data is saved on each server, so other servers cannot access the session status data of the current server. This also means that an application pool recycle operation will cause session state loss. This solution runs the fastest without considering the off option. However, unless we apply the sticky session mechanism, this solution cannot work normally in the Web farm environment. If you use the sticky session mechanism and do not use web garden, inproc is a feasible solution.
To set the session Status in the web. config file or other configuration files, you can add a sessionstate tag in the <system. Web> Configuration section of the configuration file, as shown in the following code.
<Configuration>
<System. Web>
<Sessionstate mode = "inproc"/>
</System. Web>
</Configuration>
2. StateServer
StateServer is another solution provided by Microsoft, but this solution does not provide the Failover function. When ASP is successfully installed on the server. net, Windows Services will add an item named ASP.. Net State service, which is disabled by default, but can be enabled at any time. We need to set the Service Startup Mode to automatic, so that the service will be automatically started every time the system restarts.
By default, Asp. the net sessionstate service cannot be remotely accessed. If you need to remotely run ASP. net sessionstate service, you need to set the value of HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ aspnet_state \ Parameters \ allowremoteconnection to 1 in the registry.
<Sessionstate mode = "StateServer"/>
If you do not want to use the default status server in the local server, you can set parameters as needed. <Sessionstate mode = "StateServer" stateconnectionstring ="
Tcpip = 10.0.0.10: 42424 "/>
3. sqlserver
The third solution provided by Microsoft is the SQL Server session status. If an sqlserver cluster is used in the current application running environment, this solution is a very suitable solution. Compared with other solutions, the SQL Server session state has the highest performance overhead, but because SQL Server session State provides redundancy support, the impact of this solution on performance is negligible. Before deploying such a solution, ensure that the system performance meets the requirements of the current application, and ensure that the system has good scalability.
SQL Server uses the aspnet_regsql.exe Tool
4. Custom
ASP. NET supports custom session Status providers. Therefore, we can implement a solution different from Microsoft's solutions. Similar to other options, once a custom solution is developed and installed and deployed on the server. the config file and the Web. the config file is updated to point to the custom provider.
5. Off
The session state can be completely closed, which makes sense in some cases, because after the session state is enabled, the system performance will decrease even if the session state is not used. To disable the session status, we can perform operations according to the content in the "inproc" section. The only difference is that we select off instead of in process. In IIS manager, this method is called not enabled.
Third-party session status solution
Scaleout software (www.scaleoutsoftware.com) and alachisoft (www.alachisoft.com) are two famous third-party software vendors dedicated to providing web farm session Status solutions. The products of the two third-party software vendors can be applied to high-availability and high-scalability web farm systems, and session status data can be saved in the process, and all modifications can be copied immediately; in addition, the product supports saving session data outside the process. To save session data outside the process, you need to use a custom Workflow running on all servers.