I have a Web API that I need to configure multiple route (currently using convention-based) but it looks like the first route is grabbing every request.
Here are the routes from WebApiConfig.cs
config.Routes.MapHttpRoute(
name: "MyProtApi",
routeTemplate: "api/{controller}/{action}/{myprotocolsid}",
defaults: new { myprotocolsid = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
name: "AssessmentApi",
routeTemplate: "api/{controller}/{action}/{assessmentid}",
defaults: new { assessmentid = RouteParameter.Optional }
);
Whats working:
- Any calls to the "MyProtocols" controller whether there is an
"myprotocolsid" provided or not
- /api/myprotocols/getbyid/642ff9cd-fb32-4a79-aaa4-088278796bb0
- public MyProtocolsViewModel GetById(Guid myProtocolsId)
- Calls to the "Assessment" controller
that don't provide an "assessmentid"
- /api/assessment/list
- public IEnumerable List()
Whats not working
- Calls to the "Assessment" controller that have an "assessmentid" parameter
- /api/assessment/getbyid/8ba32ce6-8a97-4211-b649-afcc8e194f21
- public AssessmentTreeViewModel GetById(Guid assessmentId)
- "No action was found on the controller 'Assessment' that matches the request."