会话状态

有三种处理模型:

 

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.sql

    This 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" />
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值