Using web-api i go to /api/cat/orders/
I specified the following routes and controller methods. I expected that the "ApiRouteWithCategoryAndExtId" route and the "GetMessageByCategoryExtId" method would be used since I made "extid" optional. But it is using the default Get method.
(/api/cat/orders/id18 uses GetMessageByCategoryExtId, but then extid is not optional)
What am I doing wrong?
Routes:
config.Routes.MapHttpRoute(
name: "ApiRouteUniqueId",
routeTemplate: "api/def/{id}",
defaults: new { id = RouteParameter.Optional, controller = "Default" }
);
config.Routes.MapHttpRoute(
name: "ApiRouteWithCategoryAndExtId",
routeTemplate: "api/cat/{category}/{extid}",
defaults: new { extid = RouteParameter.Optional, controller = "Default"}
);
Controller:
public string Get()
public HttpResponseMessage GetMessageById(int id)
public HttpResponseMessage GetMessageByCategoryExtId(
string category, string extid)