开发者

How to create a RouteValueDictionary given a virtual path

开发者 https://www.devze.com 2022-12-12 22:20 出处:网络
I would like to know if there is a method that, given a virtual path, will return a collection of parameter names and values for a route that matches the path. I need this to get the parameters of the

I would like to know if there is a method that, given a virtual path, will return a collection of parameter names and values for a route that matches the path. I need this to get the parameters of the URL on the target page without resorting to hard-coding a regular expression.

This is I guess the reverse of RouteTable.Routes.开发者_如何转开发GetVirtualPath that takes a RouteValueDictionary and returns a virtual path.

Is this possible?

Mark


Take a look at my similar question and answers to it: String URL to RouteValueDictionary

Edit

Piotr Czapla had provided solution that does not require mocking library. Take a look if you are still interested in solving this problem

0

精彩评论

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

关注公众号