ASP.NET MVC got 405 error on HTTP DELETE request?
Asked Answered
M

2

20

I'm trying to pass the DELETE to a URL in asp.net MVC using JavaScript but however i always got 405 Method not allow return.

is there anyway to make this work?

FYI: I've put the [AcceptVerb(HttpVerb.Delete)] attribute on my controller.

DELETE /post/delete/8

this is the request

Mealtime answered 19/11, 2009 at 3:0 Comment(2)
can u show us some REQUEST data via Fiddler or FireBug, so we can double confirm what is getting requested ?Morelos
i've added the request via Firebug, that one is the request, and no data since im still testing...Mealtime
W
42

It was frustrating to me too. It is because WebDAVModule is installed by default on IIS 7.5. By removing the module, you can get rid of this frustrating restriction. Simply,

    <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true">
            <remove name="WebDAVModule"/> <- add this

from http://shouldersofgiants.co.uk/Blog/post/2009/11/27/HTTP-Error-405-With-ASPNet-MVC-and-HTTP-PUT-on-IIS-75.aspx

Whap answered 9/9, 2010 at 15:32 Comment(3)
Excellent, this helped me as well. It might just be a MVC.NET 3 thing, because I don't recall it happen in MVC.NET 2.Dative
In my case, I had to remove the PUT and DELETE verbs in WebDAV handler mapping before removing the webdave module (I guess removing whole WebDAV handlerMapping would have be fine also). By removing only the module and not the mapping, a communication exception occured for me... I also had to add PUT and DELETE verbs in ExtensionlessUrlHandler-Integrated-4.0 handler mapping verbs restrictionJohannejohannes
I can verify Charles comment, the above answer did not work for me. I had to follow Charles directions. I imagine this is a result of changes made to IIS 7.5 installation on 2008 R2.Heloise
S
0

You should check the web.config (if using IIS7, else the IIS manager for IIS6 and below) to make sure the DELETE verb is mapped to the MCV request handler.

Showman answered 19/11, 2009 at 4:36 Comment(1)
<add verb="" path=".mvc" validate="false" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> -> you mean this?Mealtime

© 2022 - 2024 — McMap. All rights reserved.