如何在IIS 7.0中增加请求超时时间?在IIS 6.0的应用程序选项卡下,可以在ASP配置设置中完成相同操作。但我找不到IIS 7.0中的ASP.NET配置部分。
如何在IIS 7.0中增加请求超时时间?在IIS 6.0的应用程序选项卡下,可以在ASP配置设置中完成相同操作。但我找不到IIS 7.0中的ASP.NET配置部分。
将以下内容添加到您的Web配置文件中
<system.web>
<httpRuntime executionTimeout="180" />
</system.web>
https://msdn.microsoft.com/zh-cn/library/e1f13641(v=vs.85).aspx
可选的 TimeSpan 属性。
指定了在 ASP.NET 自动关闭请求之前,允许执行的最大秒数。
只有当编译元素中的 debug 属性为 False 时才应用此超时。为了避免在调试时关闭应用程序,请不要将此超时设置为较大的值。
默认值为 "00:01:50"(110 秒)。
要增加请求超时时间,请将以下内容添加到web.config文件中:
<system.web>
<httpRuntime executionTimeout="180" />
</system.web>
对于特定页面,请添加以下内容
<location path="somefile.aspx">
<system.web>
<httpRuntime executionTimeout="180"/>
</system.web>
</location>
默认值为.NET 1.x的90秒。
默认值为.NET 2.0及更高版本的110秒。
IIS 7及以上版本中,<webLimits>
部分已经替代了IIS 6元数据设置中的ConnectionTimeout
、HeaderWaitTimeout
、MaxGlobalBandwidth
和MinFileBytesPerSec
。
配置示例:
<configuration>
<system.applicationHost>
<webLimits connectionTimeout="00:01:00"
dynamicIdleThreshold="150"
headerWaitTimeout="00:00:30"
minBytesPerSecond="500"
/>
</system.applicationHost>
</configuration>
供参考:有关IIS这些设置的更多信息可以在这里找到。此外,我无法通过IIS管理器的“配置编辑器”将此部分添加到web.config中,但一旦我添加并搜索配置后,它就会显示出来。
我知道问题是关于ASP的,但也许有人会发现这个答案有用。
如果您在IIS 7.5后面有一个服务器(例如Tomcat),那么您可以更改超时时间。在我的情况下,我有一个配置了Tomcat服务器的服务器群。
在这种情况下,您可以使用IIS管理器更改超时时间:
或者您可以在配置文件中更改它:
示例:
<webFarm name="${SERVER_NAME}" enabled="true">
<server address="${SERVER_ADDRESS}" enabled="true">
<applicationRequestRouting httpPort="${SERVER_PORT}" />
</server>
<applicationRequestRouting>
<protocol timeout="${TIME}" />
</applicationRequestRouting>
</webFarm>
时间${TIME}以HH:mm:ss格式显示(如果您想将其设置为90秒,则在那里输入00:01:30)
对于Tomcat(以及可能其他servlet容器),您必须记得在%TOMCAT_DIR%\conf\server.xml中更改超时时间(只需搜索Connector标记中的connectionTimeout属性,并记住它是以毫秒为单位指定的)
使用以下PowerShell命令更改执行超时时间(请求超时)
请注意,我已为默认网站提供此命令。在使用之前,请更改站点并尝试使用此命令。
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site' -filter "system.web/httpRuntime" -name "executionTimeout" -value "00:01:40"
using System;
using System.Text;
using Microsoft.Web.Administration;
internal static class Sample {
private static void Main() {
using(ServerManager serverManager = new ServerManager()) {
Configuration config = serverManager.GetWebConfiguration("Default Web Site");
ConfigurationSection httpRuntimeSection = config.GetSection("system.web/httpRuntime");
httpRuntimeSection["executionTimeout"] = TimeSpan.Parse("00:01:40");
serverManager.CommitChanges();
}
}
}
var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST/Default Web Site";
var httpRuntimeSection = adminManager.GetAdminSection("system.web/httpRuntime", "MACHINE/WEBROOT/APPHOST/Default Web Site");
httpRuntimeSection.Properties.Item("executionTimeout").Value = "00:01:40";
adminManager.CommitChanges();
appcmd.exe set config "Default Web Site" -section:system.web/httpRuntime /executionTimeout:"00:01:40"