0
I’m migrating a project to ASP.NET Core 2.0, but I’m unable to use the following routes.
Error message.
An unhandled Exception occurred while Processing the request.
Ambiguousactionexception: Multiple actions Matched. The following actions Matched route data and had all constraints satisfied:
ASP.Net Webapi2
[Route("api/[controller]")]
public class SalesController : Controller
{
// api/sales/1 -> funciona
[HttpGet]
public HttpResponseMessage Get(int id)
{
// Logic
}
// api/sales?page=1&pageSize-20 -> funciona
[HttpGet]
public HttpResponseMessage Get([FromUri] PaginationHelper pagination)
{
// Logic
}
// api/sales?me -> funciona
[ActionName("Get")]
public HttpResponseMessage GetMe(bool? me)
{
// Logic
}
}
ASP.Net Core 2.0
[Route("api/[controller]")]
public class SalesController : Controller
{
// api/sales/1 -> funciona
[HttpGet("{id:int}")]
public IActionResult Get(int id)
{
// Logic
}
// api/sales?page=1&pageSize-20 -> não funciona
[HttpGet]
public IActionResult Get([FromQuery] PaginationHelper pagination)
{
// Logic
}
// api/sales?me=false -> não funciona
[HttpGet]
public IActionResult GetMe(bool me)
{
// Logic
}
}
I had the same problem some time ago, in my case it was a route pointing to two different methods in different controllers
– João Rafael Colombo
In my case, I only have one controller, and it’s conflicting with public Iactionresult Get([Fromquery] Paginationhelper pagination) e public Iactionresult Getme(bool me)
– Willian Teleginski