HTTP Error 405.0 - Method Not Allowed - WebDAV issue? (IIS)

0

I'm trying to build a simple Web API service (Visual Studio, C#, local IIS) that has an http handler that accepts PUT and other requests

After getting everything configured, I'm trying to test the PUT event and am receiving

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

Google searches revealed that WebDAV intercepts PUT commands, so I am removing it from 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>

I'm afraid to uninstall WebDAV from my dev box, as it may break other web projects that do rely on the module.

What am I doing wrong?

iis
asp.net-web-api
put
asked on Stack Overflow Aug 13, 2016 by Igorek

1 Answer

0

Adding this snippet can resolve your problem:

  <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" />
    </handlers>
  </system.webServer>
answered on Stack Overflow Aug 14, 2016 by Ramin Esfahani • edited Jul 6, 2018 by Community

User contributions licensed under CC BY-SA 3.0