会话状态
有三种处理模型: ? 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>
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" /> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |