1

We have some specific web pages and Web Api services which call long-running back end processes; and we'd like to carefully control when they should timeout.

I have created a simple MVC 4 site (in VS2012) with a page that sleeps for 200 seconds before returning. Then I set these timeouts:

  • (in web.config) : httpRuntime executionTimeout="120"
  • (in global.asax Application_Start) : Server.ScriptTimeout = 120
  • In IIS (7.5) Manager, I went to the site > Advanced Settings > Connection Limits, and set Connection Time-out to 120

I am not able to get this page to timeout. It successfully returns after 200 seconds without timing out at 120 seconds. I even tried using curl (disabling tcp keepalive) to take the browser out of the picture: curl --no-keepalive mysiteurl

4

2 回答 2

2

首先从您已经尝试过的开始:

executionTimeOut=120表示当某个操作在服务器上运行并且需要超过 120 秒才能完成时,该操作将超时,Server.ScriptTimeout 也是如此。连接超时指定如果未建立连接,将返回连接错误的时间。

这意味着上述错误(执行超时)不会发生,除非同步进程超过 2 分钟,或者服务器端脚本运行超过 2 分钟,或者连接未建立。

你可以用什么。 我相信如果您希望页面在指定时间内超时,您应该只关心会话超时。您提到的其他超时将按预期工作,您可以依赖它们(如果您想测试事情是否正常,请参考此链接)。

如果您正在执行一些数据库操作,那么您应该考虑更改数据库连接的连接超时。

于 2013-09-12T20:23:49.093 回答
0

如果启用了调试模式,则这些超时不适用:

此超时仅在编译元素中的调试属性为 False 时适用。因此,如果 debug 属性为 True,则不必将此属性设置为较大的值,以避免在调试时关闭应用程序(来源

于 2014-12-01T02:41:46.547 回答