如何在IIS7上使用WebDAV上传web.config文件?

时间:2010-03-08 23:02:58

标签: asp.net-mvc iis web-config webdav

我想使用WebDAV将ASP.NET MVC网站复制到远程IIS 7服务器。我在IIS中创建了一个站点,启用了WebDAV并分配了一个名为“WebDAV Application Pool”的特殊应用程序池。使用Windows 7或Vista客户端,我可以将远程站点作为网络驱动器安装。到目前为止,非常好。

但是,我在将web.config文件上传到远程站点时遇到问题。一个问题是,只要上传web.config,就会使用它来配置WebDAV站点。 MVC项目的web.config文件夹中的Views文件有效地阻止了对该文件夹的访问。

要解决此问题,我已在applicationHost.config文件中配置了应用程序池:

<configuration>
  <applicationPools>
    <add name="WebDAV Application Pool"
       autoStart="true"
       enableConfigurationOverride="false" />
  </applicationPools>
</configuration>

有趣的部分是'enableConfigurationOverride`属性:

  

true 时,表示将为此应用程序池中的应用程序处理Web.config文件中的委派设置。当 false 时,此应用程序池将忽略Web.config文件中的所有设置。

这样就可以将web.config文件上传到Views文件夹而不会破坏对文件夹的访问权限。

但是,我仍然无法将web.config文件上传到根文件夹。我在applicationHost.config文件中有以下设置,以确保请求过滤不会干扰WebDAV:

<configuration>
  <location path="webdav.mysite.tld">
    <system.webServer>
      <security>
        <requestFiltering>
          <fileExtensions applyToWebDAV="false" />
          <verbs applyToWebDAV="false" />
          <hiddenSegments applyToWebDAV="false" />
        </requestFiltering>
      </security>
    </system.webServer>
  </location>
</configuration>

特别是hiddenSegments通常会阻止对web.config的访问,但将applyToWebDAV属性设置为 false 应确保在使用WebDAV时不会阻止此文件

不幸的是,我仍然无法将我的web.config文件复制到网站的根文件夹中。在Windows资源管理器中拖放到映射的WebDAV网络驱动器将导致以下错误消息:

  

错误0x80070057:参数不正确。

在线上似乎返回了HTTP状态400 Bad Request

我有什么办法可以在IIS 7上配置WebDAV来避免这个问题吗?


跟进

目前我无法重现上述问题。也许我不得不重新启动某些东西或其他未知因素来解决我的问题。最重要的是,我现在可以使用WebDAV发布一个网站。

1 个答案:

答案 0 :(得分:0)

1)打开%windir%\system32\inetsrv\config\schema\WEBDAV_schema

2)在configSchema部分

中添加以下内容
<sectionSchema name="system.codedom">
  <element name="compilers">
    <collection addElement="compiler" removeElement="remove" clearElement"clear">
      <attribute name="language" type="string" isCombinedKey="true"/>
      <attribute name="extension" type="string" isCombinedKey="true"/>
      <attribute name="type" type="string"/>
      <attribute name="warningLevel" type="int"/>
      <collection addElement="providerOption">
        <attribute name="name" type="string" isUniqueKey="true"/>
        <attribute name="value" type="string"/>
      </collection>
    </collection>
  </element>
</sectionSchema>