Andrew Bullock
Andrew Bullock

Reputation: 37378

Can I get an ASP.MVC route from a url?

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

Upvotes: 3

Views: 735

Answers (1)

bendewey
bendewey

Reputation: 40235

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

Upvotes: 1

Related Questions