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.
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.
It might match multiple routes, so something like Phil Haack's Route Debugger might be more useful. The source code is included.
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