uk en ru
aspnet

PUT and DELETE method does not work in WebAPI (error 405)

This is one of the most common cases. Hosting users face a problem when, after publishing a WebAPI application on a hosting, calls to the PUT and DELETE methods do not work. The web server returns an error:

HTTP Error 405.0 - Method Not Allowed. The page you are looking for cannot be displayed due to using an invalid method (HTTP command)

The problem is eliminated by adding the sections described below to the web.config file:

<system.webServer>
    <modules>
      <remove name="WebDAVModule"/>
    </modules>
    <handlers>
      <remove name="WebDAV" />
      <remove name="ExtensionlessUrl-Integrated-4.0" />
      <add name="ExtensionlessUrl-Integrated-4.0"
           path="*."
           verb="GET,HEAD,POST,DEBUG,DELETE,PUT"
           type="System.Web.Handlers.TransferRequestHandler"
           preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
</system.webServer>