开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜