简体   繁体   中英

Parsing a URL Using ASP.NET MVC Routing

I have a URL in string format that I want to parse to get the relevent Route Values. I could parse the string manually, but I want to use my routing configuration so I am not tied to the particular string format (so I can change the URL format easily).

I am trying to use the GetRouteData method on the RouteCollection, but this takes a HttpContextBase parameter. Obviously this works fine when the URL is the current URL, but I need to be able to pass in any URL.

In my routing unit tests I mock HttpContextBase out, but I don't want to do that in production code!

Any ideas?

Probably you find useful info here

http://forums.asp.net/t/1281667.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM