1、开启SQL SERVER代理服务
2、创建数据库
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regsql.exe -ssadd -S 192.168.1.82 -U sa -P 123456
3、创建表
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regsql.exe -ssadd -sstype p -S 192.168.1.82 -U sa -P 123456
4、web.config配置
<system.web>
<sessionState mode="SQLServer" sqlConnectionString="data source=192.168.1.82;user id=sa;password=123456" cookieless="false" timeout="20"/>
</system.web>
Things to watch for when using SQL to store the session information in a web farm scenario:
- The machine key between the servers' needs to be the same as
AspState Session
information is encrypted using the machine key. - The application path to your websites on all machines needs to be consistent as well.
- http://www.codeproject.com/Articles/104082/Configuring-ASP-session-state-on-SQL-server
aspnet_regiis.exe -i -enable