Multiple actions were found that match the request (GET)

0v3r_5kill

New Member
I am defining 2 GET methods in my controller, one named "Favorites", and another simply named "Get". In my routes, I specifically map different URL routes to these 2 different methods.However, when I hit /Api/MockUsers/Get?userId=2, I get the following error:\[quote\] Multiple actions were found that match the request\[/quote\]However, when I hit /api/MockUsers/1/favorites, it returns the data just fine. I am confused because it seems I specifically routed /Api/MockUsers/Get?userId=2 to the ACTION "Get", not "Favorites", so why is MvC4 confused?This is what my Routes look like:\[code\]routes.MapHttpRoute( name: "Users", routeTemplate: "api/MockUsers/{id}/favorites", defaults: new { controller = "MockUsers", action = "Favorites", id = 1 });routes.MapHttpRoute( name: "Api_Get", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { action = "Get", id = RouteParameter.Optional }, constraints: new { httpMethod = new HttpMethodConstraint("GET") });\[/code\]In my controller, I have 2 methods:\[code\][AcceptVerbs("GET")]public UserFavorite Favorites(long id){ Favorite f = new Favorite(1, "Favorite 1", "Favorite Type 1"); UserFavorite userFavorite = new UserFavorite(1, f); return userFavorite;}public User Get(long userId){ User u = _mockusersService.GetUser(userId); return u;}\[/code\]
 
Back
Top