Web API route not mapped to the correct url

emma93

New Member
I am trying to access the following url :\[code\]http://localhost:2727/api/SiteApi/Get?campaignId=2\[/code\]Here is configuration:\[code\]config.Routes.MapHttpRoute( name: "DetailedApi", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional });config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional });\[/code\]Action trying to mapped to \[code\]public class SiteApiController : ApiController{ ... public IEnumerable<Site> GetByCampaignId(int campaignId) { ... return sites; } }\[/code\]This is currently return "No action found". However, the Url will work if swap the order of the routes. This means there was a match. Question: My understanding of routing is that if it doesn't match the first route, it will fall back to the second route. I can understand if it's mapped to the wrong route, but it shouldn't be an error indicating something like "No match found" regardless how I order them. Have I missed anything?
 
Back
Top