I would like for my controllers to extent endpoints based on the data-type of the same variable name. For instance method A takes an int and method B takes a string. I don't want to declare a new route but rather for the routing mechanism to differentiate between ints and strings. Here is an example of what I mean.
The "ApiControllers" setup:
public class BaseApiController: ApiController
{
[HttpGet]
[Route("{controller}/{id:int}")]
public HttpResponseMessage GetEntity(int id){}
}
public class StringBaseApiController: BaseApiController
{
[HttpGet]
[Route("{controller}/{id:string}")]
public HttpResponseMessage GetEntity(string id){}
}
The "WebApionfig.cs" has the following route added:
config.Routes.MapHttpRoute(
"DefaultApi",
"{controller}/{id}",
new { id = RouteParameter.Optional }
);
I want to call "http://controller/1"
and "http://controller/one"
and get results. Instead i see the the multiple route exception.