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

Unable to use session state server

· 52CE 我爱测

This article provides resolutions for the error that occurs when you add the setting to the state server web.config.

This article helps you resolve the problem that occurs when you add the setting <httpRuntime enableVersionHeader ="false"/> to the state server web.config (master web.config) to hide the X-AspNet-Version: 2.0.50727 header while using the session management with ASP.NET state service.

Original product version:   Microsoft ASP.NET
Original KB number:   2836759

Symptoms

While using the session management with ASP.NET state service, if you add the setting <httpRuntime enableVersionHeader ="false"/> to the state server web.config (master web.config) to hide the X-AspNet-Version: 2.0.50727 header, you may receive the following error:

HttpException (0x80004005): Unable to use session state server because this version of ASP.NET requires session state server version 2.0 or above.

This exception occurs the first time the session cache is used after the application is published to the server, or after IIS is restarted, or after the application pool recycles. Subsequent uses of the session cache after the first exception is thrown do not result in an error. The session cache continues to work properly until the next application republish, IIS restart, or application pool recycle.

Cause

The X-AspNet-Version: 2.0.50727 header is sent by the state service to IIS. When sending the response back to the web application the state server should be including this header.

If we add the setting <httpRuntime enableVersionHeader ="false"/> to the state server web.config (master web.config), this header will not be sent from the state server to IIS and hence it throws the exception noted above.

Resolution

  1. Add <httpRuntime enableVersionHeader ="true"/> to the master web.config. The master web.config is found at C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config or C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\CONFIG\web.config depending on the bitness.

  2. Add <httpRuntime enableVersionHeader ="false"/> to local web.config of the application.

    [!NOTE] Make sure you restart the state service after the configuration changes.

More information

Since the X-AspNet-Version: 2.0.50727 header is sent by the state server, setting <httpRuntime enableVersionHeader ="true"/> on the master web.config will ensure that the state server is sending the header to IIS. When <httpRuntime enableVersionHeader ="false"/> is set at the application level web.config, IIS will not send the header to the browser and you will not be able to see the X-AspNet-Version: 2.0.50727 header in a network trace.

A better way to monitor the network traffic is to set just <httpRuntime enableVersionHeader ="true"/> in the master web.config and then you will see in a network trace the below snippet with the frame details being sent from the state server to IIS by ASPNET.

00 15 5D F4 C0 6D 00 15 5D F1 3E 65 08 00 45 00 00 7A 79 D2 40 00 80 06 00 00 AC 16 F2 11 AC 16
F2 2F A5 B8 12 E4 2E 55 75 CA 57 D4 A3 18 50 18 FF 15 3C DB 00 00 32 30 30 20 4F 4B 0D 0A 58 2D
41 73 70 4E 65 74 2D 56 65 72 73 69 6F 6E 3A 20 32 2E 30 2E 35 30 37 32 37 0D 0A 43 61 63 68 65
2D 43 6F 6E 74 72 6F 6C 3A 20 70 72 69 76 61 74 65 0D 0A 43 6F 6E 74 65 6E 74 2D 4C 65 6E 67 74
68 3A 20 30 0D 0A 0D 0A

..]ôÀm..]ñ>e..E..zyÒ@.?...¬.ò.¬.ò/¥¸.ä.UuÊWÔ£.P.ÿ.<Û..200 OK..X-AspNet-Version: 2.0.50727..
Cache-Control: private..Content-Length: 0....

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 08/06/2020
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

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

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