Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top