Session短时间内丢失处理

本文探讨了ASP.NET Web应用程序中使用InProc会话状态模式时出现的随机会话数据丢失现象。分析了可能的原因,包括AppDomain重启、配置文件更改等,并提供了使用StateServer或SQL Server会话模式作为解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Session Data Is Lost When You Use ASP.NET InProc Session State Mode

SYMPTOMS

Session data for ASP.NET Web applications appears to be lost at random intervals for the InProc session state mode.

CAUSE

Session state data is lost if the AppDomain or the Aspnet_wp.exe process (or the W3wp.exe process, for applications that run on Microsoft Internet Information Services [IIS] 6.0) is recycled. Generally, the AppDomain is restarted based on several factors:
Various attributes (for example, the memoryLimit attribute) have particular settings in the <processModel> section of the configuration file.
The Global.asax or the Web.config file was modified.
The Bin directory of the Web application was modified.
Virus scanning software touched some .config files.For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
InProc session mode indicates that session state is stored locally. This means that with InProc session state mode is actually stored as life objects in the AppDomain of the Web application. This is why the session state is lost when Aspnet_wp.exe (or W3wp.exe, for applications that run on Microsoft Internet Information Services [IIS] 6.0) or the AppDomain restarts.

RESOLUTION

To work around this problem, you can use StateServer or SqlServer session state mode. ASP.NET provides these other approaches for storing session state data. In the StateServer and SqlServer modes, your session state is not stored in the AppDomain of the Web application.

Note It is important to understand the behavior and the issues that are associated with each session state mode when you decide which mode is appropriate for your requirements. For more information, see the "References" section of this article.

原文: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q324772

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值