Reputation: 864
I know that on MVC all default routes should be at the bottom of the list especially if you have custom routing, is this the case for Web API? this has been my practice for both MVC Application and Web API. However, my co-worker insist, that it doesn't matter, if I am right can somebody provide me a link for a clear explanation. I've read it somewhere before but couldn't find it anymore. I tried explaining that having the default route on top, it becomes a catch-all for all routing.
Upvotes: 0
Views: 100
Reputation: 649
The official docs says The framework selects the first route in the route table that matches the URI.
The reason is basically Asp.Net Web API (and MVC) will compare your url to routing rules that u have specified (called routing table) in the order you wrote them in and directs the request towards the first successful matching rule , and the default routing rule will always match any url as it's so generic , so any other routing rules after it will never be considered .
Upvotes: 1