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.GetApplicationHostConfiguration();
ConfigurationSection authoringSection = config.GetSection("system.webServer/webdav/authoring", "Default Web Site");
authoringSection["enabled"] = true;
authoringSection["requireSsl"] = false;
serverManager.CommitChanges();
VB.NET
Imports System
Imports System.Text
Imports Microsoft.Web.Administration
Module Sample
Sub Main()
Dim serverManager As ServerManager = New ServerManager
Dim config As Configuration = serverManager.GetApplicationHostConfiguration
Dim authoringSection As ConfigurationSection = config.GetSection("system.webServer/webdav/authoring", "Default Web Site")
authoringSection("enabled") = True
authoringSection("requireSsl") = False
serverManager.CommitChanges()
End Sub
End Module
JavaScript
var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var authoringSection = adminManager.GetAdminSection("system.webServer/webdav/authoring", "MACHINE/WEBROOT/APPHOST/Default Web Site");
authoringSection.Properties.Item("enabled").Value = true;
authoringSection.Properties.Item("requireSsl").Value = false;
adminManager.CommitChanges();
VBScript
Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set authoringSection = adminManager.GetAdminSection("system.webServer/webdav/authoring", "MACHINE/WEBROOT/APPHOST/Default Web Site")
authoringSection.Properties.Item("enabled").Value = True
authoringSection.Properties.Item("requireSsl").Value = False
adminManager.CommitChanges()
以下示例配置 WebDAV 创作规则,使 WebDAV 客户端可以发布 IIS MIME 映射中未列出的文件,并添加一条向管理员组授予读取、写入和源访问权限的创作规则。
AppCmd.exe
appcmd.exe set config "Default Web Site" -section:system.webServer/webdav/authoringRules /allowNonMimeMapFiles:"True" /commit:apphost
appcmd.exe set config "Default Web Site" -section:system.webServer/webdav/authoringRules /+"[roles='administrators',path='*',access='Read, Write, Source']" /commit:apphost
使用 AppCmd.exe 配置这些设置时,必须确保将 commit 参数设置为 apphost
。 这会将配置设置提交到 ApplicationHost.config 文件中的相应位置部分。
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.GetApplicationHostConfiguration();
ConfigurationSection authoringRulesSection = config.GetSection("system.webServer/webdav/authoringRules", "Default Web Site");
authoringRulesSection["allowNonMimeMapFiles"] = true;
ConfigurationElementCollection authoringRulesCollection = authoringRulesSection.GetCollection();
ConfigurationElement addElement = authoringRulesCollection.CreateElement("add");
addElement["roles"] = @"administrators";
addElement["path"] = @"*";
addElement["access"] = @"Read, Write, Source";
authoringRulesCollection.Add(addElement);
serverManager.CommitChanges();
VB.NET
Imports System
Imports System.Text
Imports Microsoft.Web.Administration
Module Sample
Sub Main()
Dim serverManager As ServerManager = New ServerManager
Dim config As Configuration = serverManager.GetApplicationHostConfiguration
Dim authoringRulesSection As ConfigurationSection = config.GetSection("system.webServer/webdav/authoringRules", "Default Web Site")
authoringRulesSection("allowNonMimeMapFiles") = True
Dim authoringRulesCollection As ConfigurationElementCollection = authoringRulesSection.GetCollection
Dim addElement As ConfigurationElement = authoringRulesCollection.CreateElement("add")
addElement("roles") = "administrators"
addElement("path") = "*"
addElement("access") = "Read, Write, Source"
authoringRulesCollection.Add(addElement)
serverManager.CommitChanges()
End Sub
End Module
JavaScript
var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var authoringRulesSection = adminManager.GetAdminSection("system.webServer/webdav/authoringRules", "MACHINE/WEBROOT/APPHOST/Default Web Site");
authoringRulesSection.Properties.Item("allowNonMimeMapFiles").Value = true;
var authoringRulesCollection = authoringRulesSection.Collection;
var addElement = authoringRulesCollection.CreateNewElement("add");
addElement.Properties.Item("roles").Value = "administrators";
addElement.Properties.Item("path").Value = "*";
addElement.Properties.Item("access").Value = "Read, Write, Source";
authoringRulesCollection.AddElement(addElement);
adminManager.CommitChanges();
VBScript
Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set authoringRulesSection = adminManager.GetAdminSection("system.webServer/webdav/authoringRules", "MACHINE/WEBROOT/APPHOST/Default Web Site")
authoringRulesSection.Properties.Item("allowNonMimeMapFiles").Value = True
Set authoringRulesCollection = authoringRulesSection.Collection
Set addElement = authoringRulesCollection.CreateNewElement("add")
addElement.Properties.Item("roles").Value = "administrators"
addElement.Properties.Item("path").Value = "*"
addElement.Properties.Item("access").Value = "Read, Write, Source"
authoringRulesCollection.AddElement(addElement)
adminManager.CommitChanges()
即将推出:在整个 2024 年,我们将逐步取消以“GitHub 问题”作为内容的反馈机制,并将其替换为新的反馈系统。 有关详细信息,请参阅:https://aka.ms/ContentUserFeedback。
提交和查看相关反馈