大网数据广告活动
Web服务器与PHP

Session data is lost if you use InProc

· 52CE 我爱测

This article provides workarounds for the problem that session data is lost when you use ASP.NET InProc session state mode.

This article helps you resolve the problem that session data is lost when you use ASP.NET InProc session state mode.

Original product version:   ASP.NET
Original KB number:   324772

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 class or the Aspnet_wp.exe process (or the W3wp.exe process, for applications that run on IIS 7.0 or a later version) 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.

InProc session mode indicates that session state is stored locally. This means that with InProc session state mode is 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 IIS) 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.

Status

This behavior is by design.

References

For more information about ASP.NET session state management and other related information, see Session State.

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
See source applicability · Source date 04/15/2020
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。