2016-08-13 88 views
0

我試圖建立一個簡單的Web API服務(Visual Studio,C#,本地IIS),它具有接受PUT和其他請求的http處理程序HTTP錯誤405.0 - 方法不允許 - WebDAV問題? (IIS)

配置好所有配置後,我試圖測試PUT事件,我收到

HTTP Error 405.0 - Method Not Allowed error. 
Module WebDAVModule 
Notification MapRequestHandler 
Handler WebDAV 
Error Code 0x00000000 

谷歌搜索,發現WebDAV的攔截PUT命令,所以我從web.config中刪除它:

<system.webServer> 
    <handlers accessPolicy="Read, Execute, Script"> 
     <remove name="ExtensionlessUrlHandler-Integrated-4.0" /> 
     <remove name="WebDAV"/> 
     <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /> 
    </handlers> 
</system.webServer> 

恐怕從我的dev卸載的WebDAV框,因爲它可能會打破其他網頁依賴於模塊的對象。

我在做什麼錯?

回答

0

添加這個片段可以解決你的問題:

<system.webServer> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    <handlers> 
     <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" /> 
     <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" /> 
     <remove name="ExtensionlessUrlHandler-Integrated-4.0" /> 
     <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" /> 
     <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> 
     <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /> 
    </system.webServer> 
相關問題