views:

70

answers:

1

In my application, I have some controllers that use specific routes and some that use the default route. As a result, I have something like this:

//.. other more specific routes
routes.MapRoute(
                "Workout - Specific Workouts by exercise",
                "{userName}/workouts/exercise/{exerciseID}/{exerciseName}",
                new { controller = "Workout", action = "WorkoutsByExercise" }
                );

            routes.MapRoute(
                "Default",                                             
                "{controller}/{action}/{id}",                           
                new { controller = "Home", action = "Index", id = "" } 
            );
            routes.MapRoute(
                "Error",
                "{*catchall}",
                new { controller = "Error", action = "Http404" }
 );

However, if I type something like ~/Home/SomethingThatDoesntExist it will be picked up by the default router and thus never gets to my catchall route handler. I've verified this through Phil Haack's route debugger. As a result, it will try to get to that controller/action and wont find it. In return, StructureMap throws an error which bubbles up to Application_Error where I can't redirect it (despite everything I've tried and through research).

So, is there anyway around this or do I have to specify specific routes for all of my controllers and actions AND how can I redirect to a specific page/controller once I'm in Application_Error()?