WebAPI Delete not working - 405 Method Not Allowed

I found the solution eventually! If you come across the same issue, add the following to your web.config

<system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true">
        <remove name="WebDAVModule"/> <!-- ADD THIS -->
    </modules>
    ... rest of settings here

I hope this helps


In some cases removing it just from modules can produce next error:

500.21 Handler "WebDAV" has a bad module "WebDAVModule" in its module list

Module: IIS Web Core Notification: ExecuteRequestHandler"

solution was suggested here. Also need to remove it from handlers.

<system.webServer>
    <modules>
        <remove name="WebDAVModule" />
    </modules>
    <handlers>
        <remove name="WebDAV" />
    </handlers>
</system.webServer>

In my case none of the above solutions was working. This was because I had changed the name of the parameter in my Delete method.

I had

public void Delete(string Questionid)

instead of

public void Delete(string id)

I need to use the id name because that's the name that is declared in my WebApiConfig file. Note the id name in the third and fourth lines:

            config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );

I got this solution from here.