Search code examples
asp.netiisasp.net-web-apiasp.net-mvc-routing

What happens first? WebAPI Routing or web.config?


I am having some issues with routing where the web.config is setup to redirect as needed but I am thinking maybe the Web API is taking control of routing.

So I am wondering what the order is for routing in a Web API app. If I set everything to redirect to index.html on the web.config does the Web API overwrite that? Which one happens first and which one last? Does one overwrite the other?


Solution

  • If by "web.config", you are referring to the IIS Rewrite Module, then the IIS Rewrite Module normally runs first.

    Web API routing happens in the order in which you define it in the route table, so it is important that you define your routes from most specific to least specific to allow the routes near the top to miss in specific cases and allow the more general routes to run.