405 - Method Not Allowed


Issue

I had an Angular 8 app calling .NET Core 3.1 APIs. When I ran the application in local environment, there were no issues. All the API calls worked as expected.

When I deployed this application to production IIS, the only HTTP verbs that worked were GET and POST.

For the HTTP PUT and DELETE verbs, I was getting this error - 405 Method Not Allowed.

Solution

In order to resolve this issue, I had to implement the following two steps.

Step 1

Create a web.config file at the root level of the application.

Step 2

Update the web.config file to remove WebDAVModule as shown below.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <modules runAllManagedModulesForAllRequests="false">
        <remove name="WebDAVModule" />
      </modules>
    </system.webServer>
  </location>
</configuration>

Once this change was published to production, all of the HTTP verbs worked as expected.