2016-08-13 66 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> 
相关问题