.NET Web API 2和IIS PUT / DELETE无法正常工作(.NET Web API 2 and IIS PUT/DELETE not working)
在对我的Web API 2控制器的DELETE请求中,我得到:
Request URL:http://localhost/phoenix/api/apps/1245 Request Method:DELETE Status Code:404 Not Found DELETE http://localhost/myapp/api/apps/1245 404 (Not Found)
我的控制器看起来像:
[EnableCors(origins: "http://localhost", headers: "*", methods: "*", SupportsCredentials = true)] [Route("api/apps")] public class ApplicationController : ApiController { // DELETE api/apps/5 public void Delete(string id) { //apps.Delete(id); } }
我的IIS是为PUT / DELETE动词设置的:
我的web.config有* for verbs:
<system.webServer> <handlers> <remove name="ExtensionlessUrlHandler-Integrated-4.0" /> <remove name="OPTIONSVerbHandler" /> <remove name="TRACEVerbHandler" /> <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /> </handlers> </system.webServer>
我错过了什么?
On DELETE requests to my Web API 2 controller, I get:
Request URL:http://localhost/phoenix/api/apps/1245 Request Method:DELETE Status Code:404 Not Found DELETE http://localhost/myapp/api/apps/1245 404 (Not Found)
my controller looks like:
[EnableCors(origins: "http://localhost", headers: "*", methods: "*", SupportsCredentials = true)] [Route("api/apps")] public class ApplicationController : ApiController { // DELETE api/apps/5 public void Delete(string id) { //apps.Delete(id); } }
and my IIS is setup for the PUT/DELETE verbs:
and my web.config has has * for verbs:
<system.webServer> <handlers> <remove name="ExtensionlessUrlHandler-Integrated-4.0" /> <remove name="OPTIONSVerbHandler" /> <remove name="TRACEVerbHandler" /> <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /> </handlers> </system.webServer>
What am I missing?
原文:https://stackoverflow.com/questions/20083125
更新时间:2024-05-15 10:05