如何在 IIS7 上使用 WebDAV 上传 web.config 文件?
我想使用 WebDAV 将 ASP.NET MVC 网站复制到远程 IIS 7 服务器。我在 IIS 中创建了一个站点,启用了 WebDAV 并分配了一个特殊的应用程序池,我将其命名为“WebDAV 应用程序池”。使用 Windows 7 或 Vista 客户端,我可以将远程站点安装为网络驱动器。到目前为止,一切都很好。
但是,我在将 web.config
文件上传到远程站点时遇到问题。一个问题是,web.config
一旦上传,就会用于配置 WebDAV 站点。 MVC 项目的 Views
文件夹中的 web.config
文件有效地阻止了对该文件夹的访问。
为了解决这个问题,我在 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 发布网站。
I want to copy an ASP.NET MVC website to a remote IIS 7 server using WebDAV. I have created a site in IIS, enabled WebDAV and assigned a special application pool I have named "WebDAV Application Pool". Using a Windows 7 or Vista client I'm able to mount the remote site as a network drive. So far, so good.
However, I have problems uploading web.config
files to the remote site. One problem is that as soon as a web.config
has been uploaded it is used to configure the WebDAV site. The web.config
file in a Views
folder of a MVC project effectively blocks access to that folder.
To work around this problem I have configured the application pool in the applicationHost.config
file:
<configuration>
<applicationPools>
<add name="WebDAV Application Pool"
autoStart="true"
enableConfigurationOverride="false" />
</applicationPools>
</configuration>
The interesting part is the 'enableConfigurationOverride` attribute:
When true, indicates that delegated settings in Web.config files will processed for applications within this application pool. When false, all settings in Web.config files will be ignored for this application pool.
Doing this makes it possible to upload a web.config
file to the Views
folder without breaking access to the folder.
However, I'm still unable to upload a web.config
file to the root folder. I have the following settings in the applicationHost.config
file to ensure that request filtering doesn't interfere with 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>
In particular hiddenSegments
will normally block access to web.config
but setting the applyToWebDAV
attribute to false should ensure that this file isn't blocked when using WebDAV.
Unfortunately, I'm still unable to copy my web.config
file to the root folder of the site. Doing drag and drop in Windows Explorer to the mapped WebDAV network drive will result in the following error message:
Error 0x80070057: The parameter is incorrect.
On the wire it seems that the HTTP status 400 Bad Request
is returned.
Is there anything I can do to configure WebDAV on IIS 7 to avoid this problem?
Followup
Currently I'm unable to reproduce the problem I described above. Perhaps I had to restart something or some other unknown factor fixed my problem. The bottom line is that I now can publish a web site using WebDAV.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1) 打开
%windir%\system32\inetsrv\config\schema\WEBDAV_schema
2) 在
configSchema
部分中添加以下内容1) Open up
%windir%\system32\inetsrv\config\schema\WEBDAV_schema
2) Add the following inside of the
configSchema
section