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

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>
You saved me hours of debugging, Thank you
from where we put this code in dot net core project because in dot net core project we have appsetting.json file.In the dot net core project we have no file like web config. please reply thank you
Thank you!
fantastic post, very informative. I wonder why the other experts of this sector don’t notice this. You must continue your writing. I am confident, you have a huge readers’ base already!
Hey There. I found your blog using msn. This is a really well written article. I’ll make sure to bookmark it and come back to read more of your useful info. Thanks for the post. I’ll definitely comeback.
Thanks man
that solved my problem nicely
It did helped. Thanks a lot!
Great, thanks a lot!
I have read more posts about dealing with ‘405 errors’ for PUT and DELETE requests on .Net Core 3.1 than I care to mention. This was the silver bullet. Thank you VERY much for sharing this.
Thanks alot
This didn’t solved my problem (dotnet core 3.1). For several years I run app on Linux Fedora, but now I wanted to run it on Windows Server 2016 and got this error: 405 method not allowed…
continue on my previous post:
finally solved problem: go to IIS options – Common HTTP Features – removed WebDAV Publishing
Sure one solution is to remove WebDav but this solution is for those who wanna keep it.
I don’t know why this solution did not work for you, I’ve applied it to multiple servers and PCs, maybe you needed to restart IIS.
from where we put this code in dot net core project because in dot net core project we have appsetting.json file.In the dot net core project we have no file like web config. please reply thank you
You can create web.config yourself, this is required for IIS to override specific attributes, check this link to learn more about this file