I have a simple route in my project:
routes.MapRoute(
name: "api",
template: "api/{controller}/{action}");
In my controller I have two actions:
[HttpGet]
public string Get(string value)
{
return value;
}
[HttpGet]
public string Get(int id)
{
return id.ToString();
}
Now when I try to do a url like api/controller/get?id=1
it does not work because the framework cannot distinguish between two actions. As far as I remember it did work pretty well in ordinary web api because it's obvious that this url matches only one of the actions based on it's parameter. Did I do something wrong or it's not supported in the new MVC6?
Did I do something wrong or it's not supported in the new MVC6?
MVC Action Selector dosen't regard Action's parameters during select action. Therefore you can't have two actions correspond one route template. Except e.g actions have different Action Constraints (HttpPost, HttpGet).
Choose action logic in code.
In theory choosen logic between some actions based on parameters have to be into SelectBestActions method, but it do nothing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With