HTTP PUT not allowed in ASP.NET Web API

前端 未结 6 1189
一生所求
一生所求 2020-11-30 04:18

On my Web API project, I cannot perform an HTTP PUT to my resources. I\'ve read through some similar questions on this problem and I\'ve followed the recommende

6条回答
  •  生来不讨喜
    2020-11-30 04:55

    I had the same error, and traced it to a custom route that I'd defined like so:

    config.Routes.MapHttpRoute(
        name: "SomeCall",
        routeTemplate: "api/somecall/{id}",
        defaults: new { controller = "SomeCall", action = "Get" }
    );
    

    The problem here is the action = "Get" which prevented the PUT action of the same URI to respond. Removing the default action fixed the issue.

提交回复
热议问题