Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does MVC and WebApi controller share route table?

Seems by error, I had put my config.Routes.MapHttpRoute(...) under RouteConfig.RegisterRoutes(...) instead of WebApiConfig.Register(...). But even then, the WebApi controller actions seemed to work just fine.

Does this mean that if the MVC controller and Web API controllers are in the same project and namespace, are their routes put into the same Route table?

like image 214
MuKa Avatar asked Mar 21 '26 06:03

MuKa


1 Answers

are their routes put into the same Route table

Short answer would be yes.

They all end up in the same route table. Which also explains why you tend to put Web API routes before MVC routes and also why there can be route conflicts.

RouteConfig.RegisterRoutes(...) and WebApiConfig.Register(...) are just ways to organize and group related code together.

like image 119
Nkosi Avatar answered Mar 22 '26 18:03

Nkosi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!