19

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

abatishchev
  • 92,232
  • 78
  • 284
  • 421
DucDigital
  • 4,370
  • 9
  • 47
  • 93

2 Answers2

41

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

Andy
  • 5,266
  • 2
  • 37
  • 28
  • 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. – Dofs May 24 '11 at 14:04
  • 1
    Works for PUT requests too! Thanks! – Lance Fisher Jun 28 '11 at 08:40
  • 1
    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 restriction – Charles HETIER Apr 17 '13 at 10:54
  • 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. – gravidThoughts Jun 07 '14 at 22:18
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.

Josh Pearce
  • 3,229
  • 1
  • 20
  • 24