超过会话的请求队列限制

The request queue limit of the session is exceeded

我在 ASP.NET 应用程序中遇到此错误,NET 4.7.1。

超过会话的请求队列限制。

已满:

System.Web.HttpException (0x80004005): The request queue limit of the session is exceeded.
at System.Web.SessionState.SessionStateModule.QueueRef()
at System.Web.SessionState.SessionStateModule.PollLockedSession()
at System.Web.SessionState.SessionStateModule.GetSessionStateItem()
at System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData)

有什么建议吗?

.NET 4.7 中的默认行为已更改。 Retargeting guide suggests:

To restore the old behavior, you can add the following setting to your web.config file to opt-out of the new behavior.

<appSettings>
  <add key="aspnet:RequestQueueLimitPerSession" value="2147483647"/>
</appSettings>

更改行为的说明:

In the .NET Framework 4.6.2 and earlier, ASP.NET executes requests with the same Sessionid sequentially and ASP.NET always issues the Sessionid through cookies by default. If a page takes a long time to respond, it will significantly degrade server performance just by pressing F5 on the browser. In the fix, we added a counter to track the queued requests and terminate the requests when they exceed a specified limit. The default value is 50. If the limit is reached, a warning will be logged in the event log, and an HTTP 500 response may be recorded in the IIS log.

也在这里解决:https://knowledgebase.progress.com/articles/Article/The-request-queue-limit-of-the-session-is-exceeded-in-sitefinity-11-2

有时这个错误是由服务器端的许多重定向产生的,经过调查我发现事实上在我修复这个错误后用户被 ActionsFilter 重定向到相同的操作并没有发生,我想如果你调查 IIS记录你更有可能发现同样的问题。

PS.对于这种情况设置RequestQueueLimitPerSession不会解决问题。

重现:打开 IE 11 打开指定路径并按 F5 60 秒。它会生成很多对该路径的请求,如果我们查看 iis,我们会发现一些带有 win-32 status = 64 的请求

对 IIS 日志的充分分析将为您提供有关此 requests/user agent/all 已访问 paths/request 状态/...

性质的大量信息

在异常高 activity 的日子里,我在 MVC 应用程序(.NET 版本 4.7.2)中遇到了同样的错误。我通过在应用程序的数据库中添加必要的 table 索引来修复它。就我而言,解决方案不是调整“aspnet:RequestQueueLimitPerSession”设置,而是解决导致会话请求超过默认限制的有关数据库性能的潜在问题。