tags:

views:

121

answers:

1

I define routes in my global.asax, like this:

routes.MapRoute(
    "Default",
    "{controller}/{action}/{id}",
    new { controller = "Home", action = "Index", id = "" }
);

Given a url:

/somecontroller/someaction/3

is it possible to determine which route this will map to, and get the corresponding route object, with name, url template and defaults?

Thanks

+1  A: 

Phil Haack has a blog post with an ASP.NET Routing Debugger that will let you debug any and all routes.

bendewey
Thanks. Looks like I have to manually iterate over the routes and execute them on the context to see if they match. Utter crap. The more I delve into ASP.Net MVC the more I dislike it.
Andrew Bullock
If a url could mismatch severely enough to break your application, you're not defining your route structure detailed enough. If you need something specific, map your routes accordingly, and you won't have a problem.
Tomas Lycken
Also, you should be able to use the source code to the debugger project to develop your own "iterator" that can iterate over a set of links and display results as you would like to see them.
Tomas Lycken