Search code examples
asp.net-mvc-2asp.net-mvc-routingasp.net-mvc-controller

MVC2 without Routing


I have a case where MVC's routing (mapping a url to a controller) is just getting in the way. I want to circumvent it and send all urls to a single controller (no matter the format and without any attempt to parse them).

I assumed this would be easy, but I'm stuck. Help is much appreciated.


Solution

  • Write a catch-all route (global.asax) and define a default action/controller to this route..

    routes.MapRoute(
                "All",
                "{*all}",
                new { controller = "Home", action = "Index" }
            );