2010-02-07 39 views
3

我有引用的URL未直接頁的祖先文件夾指出 - 就像下面這些:如何解決網址與非祖先引用

http://www.mysite.com/home/../help/helppage.aspx 

    http://www.mysite.com/contact/../help/helppage.aspx 

    http://www.mysite.com/accounts/performing-accounts/../../help/helppage.aspx 

我希望能夠明確解決這些問題至

http://www.mysite.com/help/helppage.aspx

如何在C#中執行此操作?

+0

請參閱本之一:http://stackoverflow.com/questions/128990/absolute-url-from-base-relative-url-in-c – Gant 2010-02-07 02:03:45

回答

1
Uri uri = new Uri("http://www.mysite.com/home/../help/helppage.aspx"); 
uri.AbsoluteUri; // <- Contains http://www.mysite.com/help/helppage.aspx 
+0

+1爲正確答案:-) – 2010-02-07 02:13:12