views:

34

answers:

2

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

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

Is this possible? It seems like the catchall has to be last?

A: 

From ScottGu:

The MVC framework chooses the Controller to use by evaluating the RouteTable rules in the order that they have been registered

I think you can register after the catch-all, but it won't ever be hit because the catch-all will be hit first.

mgroves
A: 

The catch-all has to be the last parameter in the route, as it says "match the entirety of what remains of the URL."

You could fake it, though, by having just the catchall and using a custom MyRouteHandler instead of the MvcRouteHandler. Your custom route handler would just manipulate the RouteContext to split the action and id back out of the URL before passing it to the MvcRouteHandler for processing.

Levi