سؤال

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

هل كانت مفيدة؟

المحلول 2

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.

نصائح أخرى

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>

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>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top