Is it possible to have catchall followed by other parameters in ASP.NET MVC Route?

I would like to create a route that looks something like this:

routes.Add (new route ("{* url} / {action} .do / {id}", new MvcRouteHandler ())

Is it possible? Seems like the last one should be the last?

+2


a source to share


2 answers


From ScottGu :

The MVC framework selects the Controller to use by evaluating the RouteTable Rules in the order they are registered



I think you can register after catching everything, but it never gets hurt because everyone gets caught first.

0


a source


The latter should be the last parameter on the route as it says "Match whatever is left of the url".



You could fake this with just a trick and use a custom MyRouteHandler instead of MvcRouteHandler. Your custom route handler simply manipulates the RouteContext to strip the action and ID back from the URL before passing it to the MvcRouteHandler for processing.

+1


a source







All Articles