7

I have a an action on my Email Web API 2 controller:

[Authorize]
[RoutePrefix("api/Email")]
public class EmailController : ApiController {

    //...

    [HttpDelete]
    [Route("Remove/{id}")]
    private void Remove(int id) {
        _repo.Remove(id);
    }
}

When I call the action from Fiddler with DELETE http://localhost:35191/api/Email/Remove/35571 (or by any other method) I get a 500 back with the generic IIS error page that gives me no information on the error.

It seems the error is occurring before my action is ever called because setting a breakpoint within the action results in the breakpoint never being hit.

Is there some sort of configuration required to allow DELETE methods in IIS (Express)?

I've tried explicitly allowing DELETE in my web.config:

  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />

but to no avail.

Stephen Collins
  • 3,523
  • 8
  • 40
  • 61

1 Answers1

13

You have to make your exposed methods public:

[HttpDelete]
[Route("Remove/{id}")]
public void Remove(int id) {
    _repo.Remove(id);
}

If that didn't work then you probally need to remove the WebDav(web.config):

<system.webServer>
   <modules>
      <remove name="WebDAVModule" />
   </modules>
   <handlers>
      <remove name="WebDAV" />
   </handlers>
</system.webServer>
Amir Popovich
  • 29,350
  • 9
  • 53
  • 99