asp.net-web-apiweb-api-testingiis-express-10

How to allow a DELETE method with IIS Express and Web API?


I am trying to send a delete request to my Web API service via Fiddler and am getting back a 405 "Method not allowed" error.

I have read extensively about removing the "WebDAV" module in web.config and similar suggestions (WebDAV is not enabled in my applicationhost.config anyway), but nothing I have tried has worked.

My service is currently running on IIS Express 10 (launching from Visual Studio). I do have this in my web.config file:

<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler"
    preCondition="integratedMode,runtimeVersionv4.0"/>

I would have thought the verb="*" piece would have allowed DELETE, but it does not seem to work.

One other note - when I inspect the response in Fiddler, under the Security heading it says: Allow: GET, POST.

I am not sure where that "Allow" parameter is being set (I am new to Web API).

Any help would be greatly appreciated. Please let me know what other information you need from me and I will add it.

Thank you!


Solution

  • Just reproduced this by creating a new webapi project [targeting .net framework 4.7.1]

    Through Fiddler, I can hit the DELETE endpoint without any changes to web.config.

    Please make sure to use correct endpoint including the id parameter.

    e.g http:localhost:xxxx/api/values/id // please include the id and xxxx is port number.

    If http:localhost:xxxx/api/values is used without id , I get the same result 405 Method Not Allowed

    Hope this helps.