将属性路由限制为特定的HTTP动词

CMi*_*cea 5 attributerouting asp.net-mvc-5

使用AttributeRouting库,我可以将路由限制为特定的动词:

[Route("customers", HttpVerbs.Post)]
Run Code Online (Sandbox Code Playgroud)

在MVC 5中,内置了AttributeRouting,但是使用HttpVerbs时没有重载。在这种情况下,如何限制到POST的路由?

jd4*_*d4u 1

您可以指定[HttpGet()], [HttpPost()],[HttpPut()]将方法限制为一种或多种受支持的 Http 方法,