首页 > 解决方案 > 即使调试设置为 true,asp.net mvc 应用程序在生产中也会超时。谁可以帮我这个事

问题描述

我们有一个 ASP.Net MVC 应用程序。它已在生产环境中发布,并且在 WEb.config 中将 debug 设置为 true(不确定原因)。

compilation batch="true" debug="true" targetFramework="4.5"

但是应用程序仍然超时。

我想制作debug="false"并添加以下标签。

httpRuntime executionTimeout="43200" maxRequestLength="104856" targetFramework="4.5"

但是,如果应用程序超时,debug="true"那么我认为即使debug="false"与 executionTimeout 无关,它也会超时。

有什么方法可以通过 Global.asax.cs 设置超时?

编辑 1:如果进程运行超过 2 分钟,应用程序会超时。

所以这意味着会话仍然存在。

<sessionState mode="InProc" cookieless="false" timeout="60" />

对于数据库,我添加了 5 分钟的命令超时(仅用于测试目的),但仍然存在超时。

编辑2:浏览日志后,这是错误。

The remote host closed the connection. The error code is 0x800703E3

标签: c#asp.net.netmodel-view-controller

解决方案


用户会话可能正在结束,这可能会使其他一切变得无关紧要:

在 IIS 中设置: sessionState timeout="120"

或 Web.config:

<configuration>
<system.web>
<sessionState mode="InProc" timeout="120"></sessionState>
</system.web>
</configuration>

默认值为 20 分钟,因此您的 12 小时 httpruntime executiontimeout 将无关紧要。

如果您有长时间运行的脚本,请确保您有足够的初始数据库连接和命令超时的连接超时。检查日志并加载一个不依赖数据库的页面作为测试。

此外,Microsoft 文档指出:

“仅当元素中的 debug 属性设置为 false 时,此超时才适用。”</p>

https://docs.microsoft.com/en-us/dotnet/api/system.web.configuration.httpruntimesection.executiontimeout?view=netframework-4.7.2

因此,在 debug 当前设置为 true 的情况下,executiontimeout 设置将不会执行任何操作,直到 debug 更改为 false。


推荐阅读