I am trying to figure out how i can create a route configuration so that all URLS will goto the same VIEW (Page).
CUrrently of course if i do for example
/Products/Id
Then this would look in the Products controller.
I would like to always goto my MainController and the same action no matter what the URL is
Is this possible?
Thanks in advance
This is possible to be done with a catchAll
route:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"CatchAll",
"{*url}",
new { controller = "Main", action = "Index" }
);
}
Alternatively you could have your default route and put the catchAll route after it so that if no other route is matched, the catchAll route will get it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With