<webdav> 元素包含为 Internet Information Services (IIS) 7 配置 Web 分布式创作和版本管理 (WebDAV) 的设置。 WebDAV 是基于 Internet 的开放标准,支持通过 HTTP 和 HTTPS 连接编辑网站。 与文件传输协议 (FTP) 相比,WebDAV 具有多项优势,最显著的优势是提供更多安全选项,并且可使用单一 TCP 端口进行所有通信。

WebDAV 7.0 和 WebDAV 7.5 模块是 IIS 7.0 带外提供的,需要从以下 URL 下载和安装模块:

https://www.iis.net/expand/WebDAV

在 Windows 7 和 Windows Server 2008 R2 中,WebDAV 7.5 模块作为 IIS 7.5 的功能提供,因此无需再下载 WebDAV。

要在 Web 服务器中支持 WebDAV 发布,必须安装 WebDAV 模块。 为此,请按照以下步骤操作。

Windows Server 2012 或 Windows Server 2012 R2

  • 在任务栏上,单击 “服务器管理器”。
  • 在“服务器管理器”中,单击“管理”菜单,然后单击“添加角色和功能”
  • 在“添加角色和功能”向导中,单击“下一步” 。 选择安装类型,然后单击“下一步”。 选择目标服务器,然后单击“下一步”。
  • 在“服务器角色”页,依次展开“Web 服务器 (IIS)”、“Web 服务器”和“常见 HTTP 功能”,然后选择“WebDAV 发布”。 单击 “下一步”
  • 在“选择功能” 页上,单击“下一步”
  • “确认安装选择” 页上,单击 “安装”
  • 在“结果” 页面中单击“关闭”
  • Windows 8 或 Windows 8.1

  • 在“开始”屏幕上,将指针一直移动到左下角,右键单击“开始”按钮,然后单击“控制面板”
  • 在“控制面板”中,单击“程序与功能”,然后单击“打开或关闭 Windows 功能”
  • 依次展开“Internet Information Services”、“万维网服务”和“常见 HTTP 功能”,然后选择“WebDAV 发布”。
  • 单击“确定”。
  • 单击“关闭” 。
  • Windows Server 2008 R2

  • 在任务栏上,单击“开始”,指向“管理工具”,然后单击“服务器管理器”
  • 在“服务器管理器”层次结构窗格中,展开“角色”,然后单击“Web 服务器 (IIS)”
  • 在“Web 服务器 (IIS)”窗格中,滚动到“角色服务”部分,然后单击“添加角色服务”
  • 在“添加角色服务向导”的“选择角色服务”页,展开“常见 HTTP 功能”,选择“WebDAV 发布”,然后单击“下一步”。
  • “确认安装选择” 页中,单击 “安装”
  • 在“结果” 页面中单击“关闭”
  • Windows 7

  • 在任务栏上,单击“开始”,然后单击“控制面板”
  • 在“控制面板”中,单击“程序与功能”,然后单击“打开或关闭 Windows 功能”
  • 依次展开“Internet Information Services”、“万维网服务”和“常见 HTTP 功能”
  • 选择“WebDAV 发布”,然后单击“确定”。

    Windows Server 2008 或 Windows Vista

  • 从以下 URL 下载安装包:

  • https://www.iis.net/expand/WebDAV
  • 按照以下演练中的说明安装 WebDAV 模块:

  • 在 IIS 7.0 上安装和配置 WebDAV
  • 打开 Internet Information Services (IIS) 管理器:

  • 如果使用的是 Windows Server 2012 或 Windows Server 2012 R2:

  • 在任务栏上,单击“服务器管理器”,单击“工具”,然后单击“Internet Information Services (IIS) 管理器”
  • 如果使用的是 Windows 8 或 Windows 8.1:

  • 按住 Windows 键,按字母 X,然后单击“控制面板”。
  • 单击“管理工具”,然后双击“Internet Information Services (IIS) 管理器”。
  • 如果使用的是 Windows Server 2008 或 Windows Server 2008 R2:

  • 在任务栏上,单击“开始”,指向“管理工具”,然后单击“Internet Information Services (IIS) 管理器”
  • 如果使用的是 Windows Vista 或 Windows 7:

  • 在任务栏上,单击“开始”,然后单击“控制面板”
  • 双击“管理工具”,然后双击“Internet Information Services (IIS) 管理器”。
  • 打开 Internet Information Services (IIS) 管理器:

  • 如果使用的是 Windows Server 2012 或 Windows Server 2012 R2:

  • 在任务栏上,单击“服务器管理器”,单击“工具”,然后单击“Internet Information Services (IIS) 管理器”
  • 如果使用的是 Windows 8 或 Windows 8.1:

  • 按住 Windows 键,按字母 X,然后单击“控制面板”。
  • 单击“管理工具”,然后双击“Internet Information Services (IIS) 管理器”。
  • 如果使用的是 Windows Server 2008 或 Windows Server 2008 R2:

  • 在任务栏上,单击“开始”,指向“管理工具”,然后单击“Internet Information Services (IIS) 管理器”
  • 如果使用的是 Windows Vista 或 Windows 7:

  • 在任务栏上,单击“开始”,然后单击“控制面板”
  • 双击“管理工具”,然后双击“Internet Information Services (IIS) 管理器”。
  • 在 ApplicationHost.config 文件中,可在全局、站点和目录级别配置 <webdav> 元素。 Web.config 文件中的 WebDAV 设置将被忽略。

    以下示例列出了默认网站的示例 <webdav> 元素。 此示例清除所有现有创作规则,为管理员组添加一条规则,启用 WebDAV 创作,指定允许隐藏文件,启用 WebDAV 锁并指定锁提供程序,同时启用 WebDAV 属性并指定属性映射的默认 XML 命名空间。

    <location path="Default Web Site">
       <system.webServer>
          <webdav>
             <authoringRules defaultAccess="none" allowNonMimeMapFiles="true" defaultMimeType="text/plain">
                <clear />
                <add roles="administrators" path="*" access="Read, Write, Source" />
             </authoringRules>
             <authoring enabled="true" requireSsl="false">
                <fileSystem allowHiddenFiles="true" />
                <locks enabled="true" lockStore="webdav_simple_lock" requireLockForWriting="false" />
                <properties allowAnonymousPropfind="false" allowInfinitePropfindDepth="false" allowCustomProperties="true">
                   <clear />
                   <add xmlNamespace="*" propertyStore="webdav_simple_prop" />
                </properties>
             </authoring>
          </webdav>
       </system.webServer>
    </location>
    

    以下示例列出了 WebDAV 服务器的示例 <globalSettings> 元素。 此示例定义锁和属性的内置简单提供程序,并为服务器启用 WebDAV 锁。

    <system.webServer>
          <webdav>
             <globalSettings>
                <propertyStores>
                   <add name="webdav_simple_prop" image="%windir%\system32\inetsrv\webdav_simple_prop.dll" />
                </propertyStores>
                <lockStores>
                   <add name="webdav_simple_lock" image="%windir%\system32\inetsrv\webdav_simple_lock.dll" />
                </lockStores>
             </globalSettings>
             <authoring>
                <locks enabled="true" lockStore="webdav_simple_lock" />
             </authoring>
          </webdav>
       </system.webServer>
    

    以下示例为默认网站启用 WebDAV 创作,并配置该网站,使 WebDAV 创作不需要 SSL。

    AppCmd.exe

    appcmd.exe set config "Default Web Site" -section:system.webServer/webdav/authoring /enabled:"True" /requireSsl:"False"  /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 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

    提交和查看相关反馈