The request corresponds to several actions, which leads to ambiguity of actions with various parameters in ASP.NET 5 / MVC 6

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 make the url like api/controller/get?id=1, this will not work, because the structure cannot distinguish between the two actions. As far as I remember, this worked very well in a regular web api, because it is obvious that this URL matches only one of the actions based on this parameter. Did I do something wrong or didn't support in the new MVC6?

+4
source share
1 answer

- MVC6?

MVC . , . , , (HttpPost, HttpGet).

.

SelectBestActions,

+2

Source: https://habr.com/ru/post/1620109/


All Articles