UriBuilder and “../../” in uri

筅森魡賤 提交于 2019-12-24 07:47:48

问题


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.


回答1:


You could also to use:

Uri redirect = new Uri(
    new Uri("http://site.com/a/b/c.html"), "../../x.html");



回答2:


This is working fine for me. You tried to call builder.Uri.OriginalString to get the full address back?



来源:https://stackoverflow.com/questions/1968887/uribuilder-and-in-uri

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!