本文介绍了UriBuilder 和“../../"在 uri的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要合并两个网址,但似乎 UriBuilder 不支持其中包含 ../../的网址.手动编码是我唯一的选择吗?我正在尝试这样的事情:
I need to combine two urls, but it seems that UriBuilder doesn't support url's with ../../ in them. Is my only option to code this by hand? I'm trying something like this :
Uri pageUri = new Uri("http://site.com/a/b/c.html");
string redirectUrl = "../../x.html";
UriBuilder builder = new UriBuilder(pageUri);
builder.Path += redirectUrl;
感谢您提供有关如何正确执行此操作的任何提示.
Thanks for any tips on how to do this the right way.
推荐答案
您也可以使用:
Uri redirect = new Uri(
new Uri("http://site.com/a/b/c.html"), "../../x.html");
这篇关于UriBuilder 和“../../"在 uri的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!