问题
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