WebDAV 创作 <authoring>

概述

<authoring> 元素指定 WebDAV 的站点级设置。 其中最重要的设置是是否为网站启用 WebDAV 创作。 其他元素定义 WebDAV 模块的行为,例如兼容性选项以及 WebDAV 模块如何使用属性、锁定和基础文件系统。

兼容性

版本 说明
IIS 10.0 <authoring> 元素在 IIS 10.0 中未进行修改。
IIS 8.5 <authoring> 元素在 IIS 8.5 中未进行修改。
IIS 8.0 <authoring> 元素在 IIS 8.0 中未进行修改。
IIS 7.5 <authoring> 元素作为 IIS 7.5 的功能提供。
IIS 7.0 <authoring> 元素是在 IIS 7.0 的独立下载项 WebDAV 7.0 中引入的。
IIS 6.0 空值

注意

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

  1. 在任务栏上,单击 “服务器管理器”。
  2. 在“服务器管理器”中,单击“管理”菜单,然后单击“添加角色和功能”。
  3. 在“添加角色和功能”向导中,单击“下一步”。 选择安装类型,然后单击“下一步”。 选择目标服务器,然后单击“下一步”。
  4. 在“服务器角色”页,依次展开“Web 服务器 (IIS)”、“Web 服务器”和“常见 HTTP 功能”,然后选择“WebDAV 发布”。 单击 “下一步”
    Image of Web Server and Common H T T P Features pane expanded with Web DAV Publishing selected.
  5. 在“选择功能”页上,单击“下一步”
  6. “确认安装选择”页上,单击“安装”
  7. 在“结果” 页面中单击“关闭”

Windows 8 或 Windows 8.1

  1. 在“开始”屏幕上,将指针一直移动到左下角,右键单击“开始”按钮,然后单击“控制面板”
  2. 在“控制面板”中,单击“程序与功能”,然后单击“打开或关闭 Windows 功能”。
  3. 依次展开“Internet Information Services”、“万维网服务”和“常见 HTTP 功能”,然后选择“WebDAV 发布”。
    Image of Common H T T P Features pane in Turn Windows features on or off page expanded with Web DAV Publishing selected.
  4. 单击“确定”。
  5. 单击“关闭” 。

Windows Server 2008 R2

  1. 在任务栏上,单击“开始”,指向“管理工具”,然后单击“服务器管理器”。
  2. 在“服务器管理器”层次结构窗格中,展开“角色”,然后单击“Web 服务器(IIS)”。
  3. 在“Web 服务器 (IIS)”窗格中,滚动到“角色服务”部分,然后单击“添加角色服务”。
  4. 在“添加角色服务向导”的“选择角色服务”页,展开“常见 HTTP 功能”,选择“WebDAV 发布”,然后单击“下一步”。
    Screenshot of Common H T T P Features node in Select Role Services page expanded with Web DAV Publishing selected.
  5. “确认安装选择”页中,单击“安装”
  6. 在“结果” 页面中单击“关闭”

Windows 7

  1. 在任务栏上,单击“开始”,然后单击“控制面板”。
  2. 在“控制面板”中,单击“程序与功能”,然后单击“打开或关闭 Windows 功能”。
  3. 依次展开“Internet Information Services”、“万维网服务”和“常见 HTTP 功能”
  4. 选择“WebDAV 发布”,然后单击“确定”。
    Image of World Wide Web Services and Common H T T P Features pane expanded on Turn Windows features on or off page with Web DAV Publishing selected.

Windows Server 2008 或 Windows Vista

操作方式

如何启用 WebDAV 发布

  1. 打开 Internet Information Services (IIS) 管理器:

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

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

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

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

      • 在任务栏上,单击“开始”,然后单击“控制面板”。
      • 双击“管理工具”,然后双击“Internet 信息服务(IIS)管理器”。
  2. 在“连接”窗格中,展开服务器名称,然后转到要在其中启用 WebDAV 发布的站点、应用程序或目录

  3. 在“主页”窗格中,双击“WebDAV 创作规则”。
    Image of Home pane displaying Web DAV Authoring Rules selected.

  4. 在“操作”窗格中,单击“启用 WebDAV”。
    Image of Actions pane in Web DAV Authoring Rules page displaying Enable Web DAV option.

注意

启用 WebDAV 发布后,需要先添加创作规则,然后用户或组才能将内容发布到服务器。 有关如何创建创作规则的详细信息,请参阅 authoringRules 主题。

配置

<authoring> 元素只能在 ApplicationHost.config 文件中的服务器级别进行配置。 如果 <authoring> 元素是在其他级别定义的,或是包含在 Web.config 文件中,则将被忽略。

特性

属性 说明
compatFlags 可选 flags 属性。

指定 WebDAV 的兼容性选项。 早期版本 Microsoft WebDAV 实现中使用了多种行为,此属性中的标记指定了新版 WebDAV 模块将实现哪些行为。

compatFlags 属性的值可以是下列其中一个。 如果指定多个值,请用逗号 (,) 分隔。 默认值为 MsAuthorVia, MultiProp, CompactXml, IsHidden, IsCollection
说明
None 不应使用兼容性选项。

数值为 0
MsAuthorVia

指定 WebDAV 模块是否应将“MS-Author-Via”标头返回到 WebDAV 客户端。

注意:某些 WebDAV 客户端需要此标头。

数值为 1

MultiProp 指定是否应允许 WebDAV 请求中使用多个 <prop> 语句。

注意:这违反了 RFC 4918,但一些早期 WebDAV 实现支持此语法。


数值为 2
CompactXml 指定 WebDAV 模块返回的 XML 是否应采用分层格式。

注意:通常 WebDAV 模块将仅返回不带 CRLF 字符和缩进的 XML 响应。 这可以减少网络传输数据的大小,但如果没有 XML 分析程序,就很难读取数据。

数值为 4
IsHidden 指定应支持 IsHidden 伪实时属性。

注意:此属性是 RFC 4918 中未定义的非正式标准。

数值为 8
IsCollection 指定应支持 IsCollection 伪实时属性。

注意:此属性是 RFC 4918 中未定义的非正式标准。

数值为 16
enabled 可选的 Boolean 属性。

如果启用了 WebDAV 创作,则为 true;否则为 false

默认值为 false
maxAllowedXmlRequestLength 可选 uint 属性。

指定 WebDAV 请求的请求 XML 正文的最大长度(以字节为单位)。

注意:此属性已添加到 WebDAV 7.5 和 IIS 7.5 中

默认值为 1000000
requireSsl 可选的 Boolean 属性。

如果 WebDAV 创作需要 SSL,则为 true;否则为 false。 要求 WebDAV 创作提供 SSL 提供了额外安全层,但增加了每个请求的处理开销。

默认值为 false

子元素

元素 说明
fileSystem 可选元素。

指定 WebDAV 模块如何与基础文件系统交互。
locks 可选元素。

指定 WebDAV 锁定设置。
properties 可选元素。 指定 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 创作,并配置该网站,使 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 文件中的相应位置部分。

C#

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 创作不需要锁。

AppCmd.exe

appcmd.exe set config "Default Web Site" -section:system.webServer/webdav/authoring /locks.enabled:"True" /locks.lockStore:"webdav_simple_lock" /locks.requireLockForWriting:"False" /commit:apphost

注意

使用 AppCmd.exe 配置这些设置时,必须确保将 commit 参数设置为 apphost。 这会将配置设置提交到 ApplicationHost.config 文件中的相应位置部分。

C#

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");

         ConfigurationElement locksElement = authoringSection.GetChildElement("locks");
         locksElement["enabled"] = true;
         locksElement["lockStore"] = @"webdav_simple_lock";
         locksElement["requireLockForWriting"] = 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")

      Dim locksElement As ConfigurationElement = authoringSection.GetChildElement("locks")
      locksElement("enabled") = True
      locksElement("lockStore") = "webdav_simple_lock"
      locksElement("requireLockForWriting") = 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");
var locksElement = authoringSection.ChildElements.Item("locks");
locksElement.Properties.Item("enabled").Value = true;
locksElement.Properties.Item("lockStore").Value = "webdav_simple_lock";
locksElement.Properties.Item("requireLockForWriting").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")
Set locksElement = authoringSection.ChildElements.Item("locks")
locksElement.Properties.Item("enabled").Value = True
locksElement.Properties.Item("lockStore").Value = "webdav_simple_lock"
locksElement.Properties.Item("requireLockForWriting").Value = False

adminManager.CommitChanges()

以下示例将配置 WebDAV 属性设置,以禁用匿名和无限深度属性查询,并使用映射到内置 webdav_simple_prop 提供程序的默认 XML 命名空间来启用自定义属性。

AppCmd.exe

appcmd.exe set config "Default Web Site" -section:system.webServer/webdav/authoring /properties.allowAnonymousPropfind:"False" /commit:apphost

appcmd.exe set config "Default Web Site" -section:system.webServer/webdav/authoring /properties.allowInfinitePropfindDepth:"False" /commit:apphost

appcmd.exe set config "Default Web Site" -section:system.webServer/webdav/authoring /properties.allowCustomProperties:"True" /commit:apphost

appcmd.exe set config "Default Web Site" -section:system.webServer/webdav/authoring /+"properties.[xmlNamespace='*',propertyStore='webdav_simple_prop']" /commit:apphost

注意

使用 AppCmd.exe 配置这些设置时,必须确保将 commit 参数设置为 apphost。 这会将配置设置提交到 ApplicationHost.config 文件中的相应位置部分。

C#

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");

         ConfigurationElement propertiesElement = authoringSection.GetChildElement("properties");
         propertiesElement["allowAnonymousPropfind"] = false;
         propertiesElement["allowInfinitePropfindDepth"] = false;
         propertiesElement["allowCustomProperties"] = true;

         ConfigurationElementCollection propertiesCollection = propertiesElement.GetCollection();

         ConfigurationElement addElement = propertiesCollection.CreateElement("add");
         addElement["xmlNamespace"] = @"*";
         addElement["propertyStore"] = @"webdav_simple_prop";
         propertiesCollection.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 authoringSection As ConfigurationSection = config.GetSection("system.webServer/webdav/authoring", "Default Web Site")

      Dim propertiesElement As ConfigurationElement = authoringSection.GetChildElement("properties")
      propertiesElement("allowAnonymousPropfind") = False
      propertiesElement("allowInfinitePropfindDepth") = False
      propertiesElement("allowCustomProperties") = True

      Dim propertiesCollection As ConfigurationElementCollection = propertiesElement.GetCollection

      Dim addElement As ConfigurationElement = propertiesCollection.CreateElement("add")
      addElement("xmlNamespace") = "*"
      addElement("propertyStore") = "webdav_simple_prop"
      propertiesCollection.Add(addElement)

      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");
var propertiesElement = authoringSection.ChildElements.Item("properties");
propertiesElement.Properties.Item("allowAnonymousPropfind").Value = false;
propertiesElement.Properties.Item("allowInfinitePropfindDepth").Value = false;
propertiesElement.Properties.Item("allowCustomProperties").Value = true;

var propertiesCollection = propertiesElement.Collection;

var addElement = propertiesCollection.CreateNewElement("add");
addElement.Properties.Item("xmlNamespace").Value = "*";
addElement.Properties.Item("propertyStore").Value = "webdav_simple_prop";
propertiesCollection.AddElement(addElement);

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")
Set propertiesElement = authoringSection.ChildElements.Item("properties")
propertiesElement.Properties.Item("allowAnonymousPropfind").Value = False
propertiesElement.Properties.Item("allowInfinitePropfindDepth").Value = False
propertiesElement.Properties.Item("allowCustomProperties").Value = True

Set propertiesCollection = propertiesElement.Collection

Set addElement = propertiesCollection.CreateNewElement("add")
addElement.Properties.Item("xmlNamespace").Value = "*"
addElement.Properties.Item("propertyStore").Value = "webdav_simple_prop"
propertiesCollection.AddElement(addElement)

adminManager.CommitChanges()