Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET web API HTTP Delete 405 Method Not Allowed

I already worked with web API and had a lot of problems like posting multiple parameters. I upgraded to WebApi2 to use routing attributes and now have problems like:

"message":"The requested resource does not support http method 'DELETE'."

I spent all day searching Stack Overflow and the web to solve the problem:

  • Removed webdav
  • In http protocol allow all get,put,post,delete
  • Added the [HTTPDelete] attribute
  • Added name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"
  • Searched Google for the necessary help here

Can someone please guide me on this?

like image 899
user2997115 Avatar asked Dec 07 '13 19:12

user2997115


People also ask

How do I fix 405 Method not allowed in IIS?

If you don't need to use WebDAV, then the easiest and the best way to fix "405 method not allowed" issue is to remove WebDAV from your system. You can easily get this done in "Turn Windows Features On or Off" simply un-ticking the checkbox.

How do I fix 405 Method not allowed in Postman?

If you are certain you need a POST request, chances are, you're just using the wrong endpoint on the server. Again, this can only be solved if you have proper documentation to show what methods are supported for each endpoint.

What does 405 Method Not Allowed mean?

The HyperText Transfer Protocol (HTTP) 405 Method Not Allowed response status code indicates that the server knows the request method, but the target resource doesn't support this method. The server must generate an Allow header field in a 405 status code response.


1 Answers

I had the same problem. Adding the below code to your web.config should fix the problem under the system.webserver section:

<system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true">
        <remove name="WebDAVModule"/>
like image 137
Vinoth Avatar answered Nov 14 '22 07:11

Vinoth