ASP.NET Web API - PUT & DELETE Verbs Not Allowed - IIS 8

前端 未结 19 1946
Happy的楠姐
Happy的楠姐 2020-11-22 05:16

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.

19条回答
  •  被撕碎了的回忆
    2020-11-22 06:10

    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:

    [HttpPut]
    [DnnAuthorize(StaticRoles = "MyRoleNames")]
    public HttpResponseMessage UpdateMETHOD(DTO.MyObject myData)
    

提交回复
热议问题