![](/img/trans.png)
[英]IIS7 and 301 permanent redirects using the location tag in web.config
[英]How to upload web.config file using WebDAV on IIS7?
我想使用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發布網站。
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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.