Saturday 15 June 2013

asp.net mvc - How do I setup a route to capture all subsequent URL segments after the controller as a parameter? -


I want to set up a route to the following form (such as in an HTTP handler)

/

I am new to MVC routes, but I want to set up a path where this is basically

MyController / {UrlSegments}

For example, MyController / assets / images / logo.png will find my controller and pass the "property / images / logo.png" as the parameter in the path

If you like your Setting mapping:

  routes.MapRoute (name: "default", url: "{controller} / {* stuff}", default: new {controller = "default", verb = "Default Action"});   

Then it will hit when you press

  / default / one / two / three / four   

DefaultController will have the default action and you will need a string parameter that will be the name of the item

  one / two / three / four    

No comments:

Post a Comment