I have an ASP.NET MVC 4 app. For some reason, routing always throws me off. Currently, my RouteConfig.cs file has three routes:
routes.MapRoute(
"AddProductStep1",
"{controller}/products/add",
new { controller = "Core", action = "AddProduct" }
);
routes.MapRoute(
"Products",
"{controller}/products",
new { controller = "Core", action = "Products" }
);
routes.MapRoute(
"Home",
"{controller}/dashboard",
new { controller = "Core", action = "Dashboard" }
);
If I visit /core/products, I see the view associated with my products. If I visit /core/products/add, I still see the same view. I set a break point in my Controller and noticed that the Products action was getting called in both cases. That’s why I believe this is a route configuration issue. Unfortunately, I don’t understand what I’ve configured incorrectly. Can someone point me in the right direction?
Thank you!
The first route you have defined should probably be this instead
The url in mvc is controller/action/param/param/etc
Your first route is looking for Core/Products/some parameter named add