ASP.Net Core Web API PUT and DELETE Methods not allowed (405 Error)

When Deployed to Live Environment

Ran into this issue after deploying our latest web app built on ASP.Net Core (5), MVC 6 with Web API.

We are using HostForLife shared servers to host the site.

We found that both GET and POST methods worked fine but neither PUT or DELETE worked at all. We were getting a 405 Method Not Allowed error.

From reading up on this it seems to be to do with something called WebDav disallowing these action names by default. You will need to override this setting in order to get it to work.

To do this open up your web.config file. There are 2 web.config files in your project – The one you want to open is the one INSIDE the wwwroot folder.

Inside the web.config add the following 3 lines inside the already existing system.webServer node:

<system.webServer>
  <modules runAllManagedModulesForAllRequests="false">
    <remove name="WebDAVModule" />
  </modules>
</system.webServer>

Now just save your file and publish changes to your live site.

  • Thanks, you saved my day!

  • Muhammed Shafeeq

    NICE