Can I catch the whole route on the following route?

I have a default that vs .net creates in an MVC application:

    "Default",                                              // Route name
    "{controller}/{action}/{id}",                           // URL with parameters
    new { controller = "Home", action = "Index", id = "" }  // Parameter defaults


I also want to catch this route (any text after the domain name, but it cannot contain / in it. Ie no folders, just "files" in the root).



source to share

1 answer

This route will also match the url

, it will use a controller blah

with an action Index


If you want to create a specific route for blah

, you can also do this:

    new { controller = "YourControllerForBlah", action = "Index", id = "" }


Just make sure that this route is added before the default, as otherwise the default route will match first.

You can check out ASP.NET MVC Storefront Part 7 for some ideas for routing, as well as the ASP.NET Routing Debugger from Phil Haack.



All Articles