In WebApi2, do I still need to decorate my methods with the AcceptedVerbs attribute? Or is the HttpPut parameter in the Route attribute sufficient?

    [AcceptVerbs("PUT")]
    [Route("api/v1/tokens/current"), HttpPut]

Thanks guys.

有帮助吗?

解决方案

HttpPut is actually a separate attribute here and not a parameter on RouteAttribute. For your scenario you could use either AcceptVerbs or HttpPut, but in general AcceptVerbs is helpful when you want to define multiple http methods or custom http methods which by default do not have strongly typed representation in Web API (ex: HttpPut). I would prefer using HttpPut in your above scenario.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top