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();
}
}
}
或者,您可以使用 JavaScript 来实现这一点。
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 命令。
appcmd.exe set config "Default Web Site" -section:system.web/httpRuntime /executionTimeout:"00:01:40"