KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
When attempting to create a catch all route in MVC 4 (something I've found several examples of, and based my code on) it returns a 404 error. I'm running this on IIS 7.5. This seems like a straight forward solution, so what am I missing? One note, if I move the "CatchAll" route above the "Default" route it works. But of course then none of the other controllers are ever reached. Here is the code: Route.Config: routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); routes.MapRoute( "CatchAll", "{*dynamicRoute}", new { controller = "CatchAll", action = "ChoosePage" } ); Controller: public class CatchAllController : Controller { public ActionResult ChoosePage(string dynamicRoute) { ViewBag.Path = dynamicRoute; return View(); } }
Tags (comma-separated)
Save Edits
Cancel