Following routes are in my WebApiConfig.cs:
// routing for /profile/
config.Routes.MapHttpRoute(
name: "profile",
routeTemplate: "users/{userid}/profil",
defaults: new { controller = "User", userid = RouteParameter.Optional }
);
// routing for /messages/
config.Routes.MapHttpRoute(
name: "messages",
routeTemplate: "users/{userid}/messages",
defaults: new { controller = "User", userid = RouteParameter.Optional }
);
And this is the according code in the Controller:
public class UserController {
[HttpGet]
[ActionName("profile")]
public HttpResponseMessage GetProfile(int userid) {}
[HttpGet]
[ActionName("messages")]
public HttpResponseMessage GetMessages(int userid) {}
}
So basically I want to have two methods in the same controller which both take the same parameters, but are mapped to different URLs. Right now I keep getting an error about multiple actions being found - even though I have a distinction of the ActionName attribute.
What am I doing wrong? Can I have two GET methods in the same controller, taking the same input but being called on different URLs?
Thanks!