我需要將返回從URL部分正確的URL(如在瀏覽器)創建HTTP URL字符串
string GetUrl(string actual,string path) {
return newurl;
}
例如函數:
GetUrl('http://example.com/a/b/c/a.php','z/x/c/i.php') -> http://example.com/a/b/c/z/x/c/i.php
GetUrl('http://example.com/a/b/c/a.php','/z/x/c/i.php') -> http://example.com/z/x/c/i.php
GetUrl('http://example.com/a/b/c/a.php','i.php') -> http://example.com/a/b/c/i.php
GetUrl('http://example.com/a/b/c/a.php','/o/d.php?b=1') -> http//example.com/o/d.php?b=1
GetUrl('http://example.com/a/a.php','./o/d.php?b=1') -> http//example.com/a/o/d.php?b=1
阿努建議?
可能的重複[Path.Combine for Urls?](http://stackoverflow.com/questions/372865/path-combine-for-urls) – 2011-04-16 12:09:29
@Daniel A. White:謝謝,新的Uri(Uri baseUri,字符串relativeUri)按預期工作 – ekapek 2011-04-16 12:26:18