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?
After endless searching and trying the already supplied answers (adding the PUT,DELETE verbs and remove WEBdav) it just didn't work.
I went to IIS logging settings: > View Log Files. In my case W3SVC4 was the folder with the latest date, opened the folder, looked up the latest log file and saw this entry: GET /Rejected-By-UrlScan ~/MYDOMAIN/API/ApiName/UpdateMETHOD
The Update method was listed with verb GET, weird right? So I Googled for Rejected-By-UrlScan and found this link: UrlScan Broke My Blog.
I went to here: %windir%\system32\inetsrv\urlscan\UrlScan.ini
Basically, the UrlScan blocked PUT and DELETE verbs. I opened this INI file, added the PUT and DELETE to the AllowVerbs and removed them from the DenyVerbs listings. I saved the INI file and it worked! So for me these steps were necessary next to the ExtensionlessUrlHandler hints.
Windows Webserver 2008 R2 (64 bit), IIS 7.5. I'm using this in combination with DotNetNuke (DNN) WebAPI. ASP.Net 4.0 My update method:
Enable CORS (nice and neat)
1.Add CORS nuget package
2.in the WebApiConfig.cs file to Register method add bellow code :
ex:
using System.Web.Http;
3.Add bellow code into namespace of the controller include get,post,delete,put or any http method
ex:
reference :http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api
After nothing worked, I was able to solve this by below steps:
• Did not select ‘WEB DAV PUBLISHING’ IIS settings, while installing IIS. • INETMGR - Default Website – Request Filtering – HTTP Verbs – PUT as True
In IIS 8.5/ Windows 2012R2, Nothing mentioned here worked for me. I don't know what is meant by Removing WebDAV but that didn't solve the issue for me.
What helped me is the below steps;
Now everything is working.
Update your web.config
http://odetocode.com/blogs/scott/archive/2012/08/07/configuration-tips-for-asp-net-mvc-4-on-a-windows.aspx
Removes the need to modify your host configs.
For PHP, it was simply:
I imagine this will work with other handlers too.