Mozart Al Khateeb

Full Stack

Mobile

.Net Developer

ERP Developer

Mozart Al Khateeb

Full Stack

Mobile

.Net Developer

ERP Developer

Blog Post

ASP.NET Core Error 405 Method not Allowed for PUT and DELETE requests when hosted on IIS

April 8, 2019 Hosting
ASP.NET Core Error 405 Method not Allowed for PUT and DELETE requests when hosted on IIS

This error could foul you by showing two responses from the IIS

  • 405 method not allowed
  • (No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:4200’ is therefore not allowed access.)

Actually this has nothing to do with cors since when i had this issue i have already configured cors and it was working fine with POST and GET Methods. and the pain happens when your logging service does not capture any error.

I figured out the solution after two days of research and it was a problem with IIS Itself with the
WebDAVModule which seems to block PUT and DELETE methods by default and i found the solution in the following article.

All you have to do is to add the following code to the web.config:

<system.webServer>
  <modules runAllManagedModulesForAllRequests="false">
    <remove name="WebDAVModule" />
  </modules>
</system.webServer>
Taggs:
Write a comment