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?
In Asp.Net Web API - webconfig. This works in all browser.
Add the following code inside the System.web tag
Replace your system.webserver tag with this below code
Just a quick update for anyone else who might run into this issue. As of today, changing the %userprofile%\documents\iisexpress\config\applicationhost.config does NOT work any longer (this was working fine until now, not sure if this is due to a Windows update). After hours of frustration, I changed the web.config to add these handlers to system.webserver to get it to work:
Here is how you allow extra HTTP Verbs using the IIS Manager GUI.
In IIS Manager, select the site you wish to allow PUT or DELETE for.
Click the "Request Filtering" option. Click the "HTTP Verbs" tab.
Click the "Allow Verb..." link in the sidebar.
In the box that appears type "DELETE", click OK.
Click the "Allow Verb..." link in the sidebar again.
In the box that appears type "PUT", click OK.
The another reason can be the following:
I changed my Url for Web Api method according to this answer:
But this method creates link like:
This works correctly with GET and POST requests but not with PUT or DELETE.
So I just replaced it with:
and it fixed the problem.
Change Your Web.Config file as below. It will act like charm.
In node
<system.webServer>
add below portion of codeAfter adding, your Web.Config will look like below
Remove the WebDAV works perfectly for my case:
it always better to solve the problem through the web.config instead of going to fix it through the iis or machine.config to grantee it wouldn't happen if the app hosted at another machine