Reputation: 8331
I would like to set up routing so that I can use two different Get methods on the same controller.
[HttpGet]
public bool IsServerRunning()
{
return true;
}
[HttpGet]
public string GetVersion()
{
return typeof(IVRLookupController).Assembly.GetName().Version.ToString();
}
The default route is
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
This will route will throw and error that two methods fit the route. How do I set up routing to handle these two methods?
Upvotes: 1
Views: 1438
Reputation: 11396
You could add the Action to your route:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
Upvotes: 1