Do I still need the AcceptedVerbs attribute?
-
26-12-2019 - |
سؤال
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.
لا تنتمي إلى StackOverflow