将Web.Config文件中关于Session的设定如下:
<sessionState mode=´StateServer´ stateConnectionString=´tcpip=127.0.0.1´ sqlConnectionString=´data source=127.0.0.1;Trusted_Connection=yes´ cookieless=´true´ timeout=´60´/>
同时将服务中的"ASP.NET 状态服务"设置为自动启用,这样的话,session就不依赖于某一进程了.
另一种办法就是将Session保存到SqlServer数据库中.
附:
默认配置情况下,Web.Config文件中关于Session的设定如下:
<sessionState mode=´InProc´ stateConnectionString=´tcpip=127.0.0.1´ sqlConnectionString=´data source=127.0.0.1;Trusted_Connection=yes´ cookieless=´true´ timeout=´60´/>
sessionState标签中有个属性mode,它可以有3种取值:InProc、StateServer,SQLServer(大小写敏感) 。默认情况下是InProc,也就是将Session保存在进程内(IIS5是aspnet_wp.exe,而IIS6是W3wp.exe),这个进程不稳定,在某些事件发生时,进程会重起,所以造成了存储在该进程内的Session丢失。
本文介绍了当网站部署到服务器后出现登录超时的情况时,可通过修改Web.Config文件中的Session设置来解决。提供了两种方案:一是使用StateServer模式并确保ASP.NET状态服务自动启动;二是将Session保存到Sql Server数据库。
1万+

被折叠的 条评论
为什么被折叠?



