开发者

given a url, can I get which route mapped? similiar to how mvc does it internally?

开发者 https://www.devze.com 2023-01-05 00:21 出处:网络
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 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

精彩评论

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