开发者

How to resolve url with non-ancestor references

开发者 https://www.devze.com 2022-12-19 04:37 出处:网络
I have urls with references to folders that are not direct ancestors of the page pointed to - like these below:

I have urls with references to folders that are not direct ancestors of the page pointed to - like these below:

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

    http://www.mys开发者_Python百科ite.com/contact/../help/helppage.aspx

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

I'd like to be able to unambiguously resolve these to

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

How do I do this in C#?


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号