![](/img/trans.png)
[英]One route for multiple action( difference name, http verb) in Web API
[英]Multiple route point to same web api action
我想将两条不同的路线指向相同的Get操作方法
[Authorize]
[Route("{sportType}")]
[Route("{sportType}/{regular}")]
public async Task<Player> Get(string sportType, string regular)
{
...
是否可以在上面指定类似的内容? 还是我需要创建一个单独的动作?
上面的代码给我以下错误
No HTTP resource was found that matches the request URI
请尝试以下操作:
[Authorize]
[Route("{sportType}/{regular?}")]
public async Task<Player> Get(string sportType, string regular)
{
...
这也可能对您有帮助: 属性路由
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.