سؤال

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