MVC 4. IIS 7.5 PUT returning 405
Asked Answered
C

3

10

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

Concordat answered 5/9, 2012 at 7:15 Comment(0)
C
1

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.

Concordat answered 6/9, 2012 at 15:3 Comment(0)
R
26

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>
Remittent answered 27/11, 2012 at 5:47 Comment(2)
My web.config already had the runAllManagedModulesForAllRequests="true". Adding in the remove WebDAV lines above worked great for me.Hagfish
I thought I'd already done this, but I only removed the handler - not the module. Thanks!Noumenon
C
1

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.

Concordat answered 6/9, 2012 at 15:3 Comment(0)
T
0

Putting my 2 cents in... Clicking on my site under iis showed 'WebDAV Authoring Rules' as the last entry under 'IIS'. Double-clicking on that showed 'The WebDAV feature has been disabled.' alert on the right and there was a link for 'Enable WebDAV' but it still didn't work. I followed Stanomatic's suggestion above, the handlers section didn't matter, and my modules looked like this:

<modules runAllManagedModulesForAllRequests="true" />

I just added the remove in it and that fixed my problem:

<modules runAllManagedModulesForAllRequests="true">
    <remove name="WebDAVModule" />
</modules>
Thessa answered 11/6, 2013 at 18:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.