![](/img/trans.png)
[英]Avoiding “Request matched multiple actions resulting in ambiguity” error in ASP.Net Core
[英]Request matched multiple actions resulting in ambiguity for actions with different parameters in ASP.NET 5 / MVC 6
我的項目中有一條簡單的路線:
routes.MapRoute(
name: "api",
template: "api/{controller}/{action}");
在我的控制器中,我有兩個動作:
[HttpGet]
public string Get(string value)
{
return value;
}
[HttpGet]
public string Get(int id)
{
return id.ToString();
}
現在,當我嘗試像api/controller/get?id=1
這樣的URL時,它不起作用,因為框架無法區分兩個動作。 據我所知,它在普通的web api中運行得非常好,因為很明顯這個url只根據它的參數匹配其中一個動作。 我做錯了什么或新的MVC6不支持?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.