我最近将我的 Visual Studio 升级到 2015 并将我的 Windows 升级到 10,因此我的 IIS 和 IIS Express 更改为版本 10。升级后,Put/Delete 动词导致 404 Not Found in WebAPI。这是我的 WebAPI 中的我的删除操作:
public class SlideShowApiController : ApiController
{
[AcceptVerbs("DELETE")]
[HttpDelete]
public HttpResponseMessage Delete(int id)
{
......
}
}
我发现此配置在 IIS 8 中有效,但在 IIS 10 中无效。
我正在使用 MVC 5 和 WebAPI 2,我的请求标头是:
Accept: /
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8,fa;q=0.6
AlexaToolbar-ALX_NS_PH:AlexaToolbar/alxg-3.3
Connection:keep-alive
Content-Length:5
内容类型:application/x-www-form-urlencoded;字符集=UTF-8
Cookie:ASP.NET_SessionId=vu5joofojlqjs0qd4susdxxa;
__RequestVerificationToken=hGDy2Mm9BHqAAdGBlTqOzsSFnfvRPBbR87lIKUgkInKLpuFgb4JGcq-c817EtV96VZ8-YbLq85SusCVALYZWrAyAEZZdiiYWEMWaQxFGDCs1;_USERDATA=c099a18b-facf-4b67-9037-1961ffadc326; .ASPXAUTH=22B333AD3B0F591C08C35ACCF1014B4FCB326037EFFA5312382B437A323E58AC5896B3340F972A36AA9C1E3782948745310FBD51E9EB005013ABA934B2E789DA91EC4635E85D7445B635AC05BAE9FB2631E749382A5F8EF75DBFB1E5F84C336A0DAF1663625596AEEE4A14398911AED816E1617C6D6B1D95665F72969ED864A177E5A6458C79E4CD74BF5D950C5B7EA061367CAF450C6762A7F0A0777817E8A0C68C018D6E3E780564503FADEEA0517A29280927D957B1C0A8657EA8C2776198DEB42242D093F2C683F47C05DB04C3B0
Host:localhost: 11631
Origin: http://localhost:11631
Referer: http://localhost:11631/WebManagemenet/SlideShow
User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36
X-Requested-With:XMLHttpRequest