In my controller UserApiController, I have the following functions:
public object GetUsers(string CountryID, string StateID)
{
//biz
}
public object GetPositions(int CompanyID, int DepartmentID)
{
//biz
}
In my controller SalesApiController, I have the following functions:
public object GetOrders(string CountryID, int CompanyID)
{
//biz
}
public object GetProducts(string CountrID, string StateID, int CompanyID)
{
//biz
}
in the web api config, I can map like this:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{CountryID}/{StateID}",
defaults: new { }
and it works for UserApiController.GetUsers as the function signature only matches with GetUsers.
now, questions:
1.how to define a route to handle different functions with same amount of parameters (either within same or different controller)
2.how to define a route to handle different functions with different amount of parameters (either within same or different controller, if possible)