I've been trying all the suggested workarounds for ASP.NET to be able to address my REST web service by HTTP Methods PUT and DELETE. However, none of them seems to work. (i.e. removing WebDAV handler or allowing all verbs to ExtensionlessHandler).
What's required in ASP.NET Core Web API (on IIS) to allow those two verbs (HTTP PUT and DELETE)?
PS: I've configured our Web API project using CORS, yet I'm accessing the web service from a web page on the same origin. So it's not a CORS issue, either.
A day after, I now found the cause for this error. The following reasons caused this error to happen:
[HttpPut]
, [HttpDelete]
). So, these attributes had to be applied (this is particular to ASP.NET Core).[HttpPut("{id}")]
, [HttpDelete("id")]
), too. (This is particular to ASP.NET Core.)See ASP.NET Core Web API: Routing by method name? .
I believe "405 Method not allowed" to be quite an inappropriate error message. It doesn't reflect any of the above three reasons and is very confusing.
I, moreover, believe that "400 Bad Request", "404 Not Found", or - rather - "501 Not Implemented" would have been rather more appropriate HTTP return states.
I created a GitHub issue on this:
"405: Method not allowed" = Misleading error message → Replace with better HTTP status code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With