Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC 4. IIS 7.5 PUT returning 405

I'm trying to use PUT in an MVC 4 application and I'm getting a 405 error.

In my routing I have a constraint on the route to allow PUT and POST, POST to the endpoint works, PUT fails with a 405.

I've followed the advice here ASP.NET Web API returns 404 for PUT only on some servers and here ASP.NET MVC got 405 error on HTTP DELETE request?

I've also deleted WeDAV from IIS, but I'm still getting the 405. Anybody have any other suggestions?

I'm also having exactly the same issue on IIS 8 (with Visual Studio 2012), for that I've followed this advice ASP.NET Web API - PUT & DELETE Verbs Not Allowed - IIS 8 and still no luck

like image 436
Kevin Jones Avatar asked Sep 05 '12 07:09

Kevin Jones


2 Answers

My hosting provider could NOT uninstall WebDAV as this would affect everyone.

This, runAllManagedModulesForAllRequests="true" , worked but was not recommended.

Many fixes included removing the module for WebDAVModule but that still didn't work. I removed the handler also, and finally I could use all verbs POST GET PUT DELETE.

Remove WebDAVModule and WebDAV in modules and handlers.

<modules>
    <remove name="WebDAVModule" />
</modules>
<handlers>
    <remove name="WebDAV" />
</handlers>
like image 59
Stanomatic Avatar answered Oct 19 '22 11:10

Stanomatic


As I said above I'm using the WebAPI and it appears that the WebAPI is 'fussy' over which verbs map to which methods. I ended up having to add the [HttpXXX] attributes (HttpPut, Get, Delete and Post) to the appropriate methods to get the routing to work as I expected it to.

like image 45
Kevin Jones Avatar answered Oct 19 '22 11:10

Kevin Jones