given a url, can I get which route mapped? similiar to how mvc does it internally?
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
精彩评论