I recently upgraded from Visual Studio 2010 to the Visual Studio 2012 RC. The installer also installs IIS 8 Express which Visual Studio now uses as the default web server.
IIS 8 is blocking my WEB API requests that use PUT AND DELETE verbs. IIS returns a 405 error, The requested resource does not support http method 'PUT'
.
I know people have issues with this in the past and there are several messages about it on Stack Overflow. With IIS 7 Express the solution was to uninstall WebDav. Unfortunately I don't see any way to do that with IIS 8.
I've tried editing out the WebDav sections from applicationhost.config but that hasn't helped. For example I removed <add name="WebDAVModule" image="%IIS_BIN%\webdav.dll" />
from the config file.
I've spent far too long on this. There must be a simple way to enable PUT and DELETE?
I am not sure if you have edited right configuration file. Try following steps
open %userprofile%\ducuments\iisexpress\config\applicationhost.config
By default bellow given entries are commented in the applicationhost.config file. uncomment these entries.
I have faced the same issue with you, then solved it, Here are solutions, I wish it maybe can help
First
In the IIS
modules
Configuration, loop up the WebDAVModule, if your web server has it, then remove itSecond
In the IIS
handler mappings
configuration, you can see the list of enabling handler, to choosethe PHP item
, edit it, on the edit page, click request restrictions button, then selectthe verbs tab
in the modal, in the specify the verbs to be handle label, check theall verbs radio
, then click ok, you also maybe see a warning, it shows us that use double quotation marks to PHP-CGI execution, then do itif done it, then restart IIS server, it will be ok
You can convert your Delete method as POST as;
Okay. I finally got to the bottom of this. You need to jump through some hoops to get the PUT and DELETE verbs working correctly with IIS8. In fact if you install the release candidate of VS 2012 and create a new WEB API project you'll find that the sample PUT and DELETE methods return 404 errors out of the box.
To use the PUT and DELETE verbs with the Web API you need to edit %userprofile%\documents\iisexpress\config\applicationhost.config and add the verbs to the ExtensionlessUrl handler as follows:
Change this line:
to:
In addition to the above you should ensure WebDAV is not interfering with your requests. This can be done by commenting out the following lines from applicationhost.config.
Also be aware that the default Web API convention is that your method name should be the same as the invoked HTTP verb. For example if you're sending an HTTP delete request your method, by default, should be named Delete.
this worked for me on iis8 together with some of the other answers. My error was a 404.6 specifically
Besides all above solutions, check if you have the "id" or any custom defined parameter in the DELETE method is matching the route config.
If you hit with repeated 405 errors better reset the method signature to default as above and try.
The route config by default will look for id in the URL. So the parameter name id is important here unless you change the route config under App_Start folder.
You may change the data type of the id though.
For example the below method should work just fine:
Note: Also ensure that you pass the data over the url not the data method that will carry the payload as body content.
Example:
Hope it helps.