加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

会话状态

发布时间:2020-12-12 15:33:20 所属栏目:MsSql教程 来源:网络整理
导读:有三种处理模型: ? 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?

有三种处理模型:

?

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" />

    (编辑:李大同)

    【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

      推荐文章
        热点阅读