Using SQL server to store asp.net session
1.运行%windir%\Microsoft.NET\Framework\version\InstallPersistSqlState.sql
It will create a database named “ASPState”
We should config the permission for asp.net process in this database.
2. Modify the web.config
<system.web>
<sessionState mode=”SQLServer” sqlConnectionString=”data source=servername;user id=uid;password=pwd” cookieless=”false”
timeout=”30″ stateNetworkTimeout=”20″/>
</system.web>
stateNetworkTimeout configuration setting is used to define the time, in seconds, that the ASP.NET Web
application will wait for the state server to respond to network requests.
By default, this time is 10 seconds.
3. If we using two IIS server or more, we need setup the same machine key in the web.config on those IIS
Sample:
<system.web>
<machineKey validation=”SHA1″ validationKey=”
F3690E7A3143C185AB1089616A8B4D81FD55DD7A69EEAA3B32A6AE813ECEECD28DEA66A
23BEE42193729BD48595EBAFE2C2E765BE77E006330BC3B1392D7C73F” />
</system.web>
! How to create a machine key
http://support.microsoft.com/?id=312906
4.所有要放入session的class必须Serializable,且尽量小.
