views:

32

answers:

2

I want a function that, given a URL, returns me the route that matches.

This is exactly what MVC does under the covers, how do they do it?

I have the source, but not sure where to look.

A: 

It might match multiple routes, so something like Phil Haack's Route Debugger might be more useful. The source code is included.

John Sheehan
A: 

Have a look at the MvcHandler class. Just a note, the ProcessRequest uses the RequestContext which is part of System.Web.Routing.

You could create your own method by deriving from the correct interfaces. This article may be of assistance

Ahmad