views:

88

answers:

2

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.

+3  A: 

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" }
        );
Mike Gleason jr Couturier
+1  A: 

Adding this to Application_Start in Global.asax.cs should work:

RouteTable.Routes.MapRoute(null, "{*path}", new { controller = "MyController", action = "HandleRequest" });

The parameter to MyAction should be called path.

Richard Poole