有三种处理模型:
1-默认是InProc
<sessionState ... mode="InProc" />
2-StateServer
Start Aspnet_state.exe. You can start it manually (from the command line) by executing the following command:
net start aspnet_state
<configuration> <system.web> <sessionState mode="StateServer" stateConnectionString="tcpip=localhost:42424" /> </system.web> </configuration><configuration> <system.web> <sessionState mode="StateServer" stateConnectionString="tcpip=192.168.1.2:42424" /> </system.web> </configuration>
Add the desired port number to the registry at HKEY_LOCAL_ MACHINE/System/CurrentControlSet/Services/aspnet_state/ Parameters/Port.
Replace 42424 with the new port number in stateConnectionString.
3-SQL Server Session State
Create the database that holds the session state. The .NET Framework SDK provides a script that creates the database for you; it’s called InstallSqlState.sql. To run it, open a command prompt window and type the following command:
osql -S localhost -U sa -P -i installsqlstate.sqlThis command creates a SQL Server database named ASPState on the host machine and adds to it all the tables, stored procedures, and other infrastructure that ASP.NET uses to access the database, as shown in Figure 9-11.
Add a mode=“SQLServer” attribute and a sqlConnectionString attribute to the sessionState element in Machine.config or a local Web.config file. The latter of these two attributes provides the information ASP.NET needs to connect to the database
<configuration> <system.web> <sessionState mode="SQLServer" sqlConnectionString="server=localhost;uid=sa;pwd=" /> </system.web> </configuration>
后两种会话状态需要对象的串行化.利用..net平台强大的串行化机制.
<sessionState timeout="60" />
Session.Abandon ();
<%@ Page EnableSessionState="false" %>
<sessionState mode="Off" />