长ASP.NET运行IIS请求超时

人气:1,089 发布:2022-09-15 标签: iis asp.net iis-6 httprequest

问题描述

我遇到从IIS的请求超时,当我运行一个长时间操作。幕后我的ASP.NET应用程序处理的数据,但正在处理的记录的数目是大的,并且因此该操作花费很长的时间。

I am experiencing a request timeout from IIS when I run a long operation. Behind the scene my ASP.NET application is processing data, but the number of records being processed is large, and thus the operation is taking a long time.

不过,我觉得IIS超时会话。这是IIS或ASP.NET会话的问题?

However, I think IIS times out the session. Is this a problem with IIS or ASP.NET session?

在此先感谢

推荐答案

如果你想允许延长为ASP.NET脚本来执行再增加Server.ScriptTimout值。默认值是.NET 1.x的90秒和110秒.NET 2.0及更高版本。

If you want to extend the amount of time permitted for an ASP.NET script to execute then increase the Server.ScriptTimout value. The default is 90 seconds for .NET 1.x and 110 seconds for .NET 2.0 and later.

例如:

// Increase script timeout for current page to five minutes
Server.ScriptTimeout = 300;

此值也可以在你的的web.config 文件中配置的的 的httpRuntime 配置元素:

This value can also be configured in your web.config file in the httpRuntime configuration element:

<!-- Increase script timeout to five minutes -->
<httpRuntime executionTimeout="300" 
  ... other configuration attributes ...
/>

根据 MSDN文档请注意

此超时仅适用于在编译的调试属性  元素是假。因此,如果调试属性为True,你做  没有这个属性设置为一个较大的值,以避免  当你在调试应用程序关闭。

"This time-out applies only if the debug attribute in the compilation element is False. Therefore, if the debug attribute is True, you do not have to set this attribute to a large value in order to avoid application shutdown while you are debugging."

如果你已经做到了这一点,但发现,你的会话到期再增加ASP.NET HttpSessionState.Timeout值:

If you've already done this but are finding that your session is expiring then increase the ASP.NET HttpSessionState.Timeout value:

例如:

// Increase session timeout to thirty minutes
Session.Timeout = 30;

此值也可以在的sessionState 配置元素的的web.config 文件中进行配置:

This value can also be configured in your web.config file in the sessionState configuration element:

<configuration>
  <system.web>
    <sessionState 
      mode="InProc"
      cookieless="true"
      timeout="30" />
  </system.web>
</configuration>

如果您的脚本需要几分钟时间来执行,并有许多并发用户再考虑改变页面到的异步页。这将增加应用程序的可扩展性。

If your script is taking several minutes to execute and there are many concurrent users then consider changing the page to an Asynchronous Page. This will increase the scalability of your application.

另一种选择,如果你有服务器管理员访问权限,就是要考虑这个长期运行的操作为候选人实施作为计划任务或Windows服务。

The other alternative, if you have administrator access to the server, is to consider this long running operation as a candidate for implementing as a scheduled task or a windows service.

770