What's the difference between Uri.ToString() and Uri.AbsoluteUri?

前端 未结 5 909
情书的邮戳
情书的邮戳 2020-12-14 13:43

As a comment to an Azure question just now, @smarx noted

I think it\'s generally better to do blob.Uri.AbsoluteUri than blob.Uri.ToString().

5条回答
  •  遥遥无期
    2020-12-14 14:12

    The following example writes the complete contents of the Uri instance to the console. In the example shown,

    http://www.cartechnewz.com/catalog/shownew.htm?date=today

    is written to the console.

    Uri baseUri = new Uri("http://www.cartechnewz.com");
    Uri myUri = new Uri(baseUri, "catalog/shownew.htm?date=today");
    Console.WriteLine(myUri.AbsoluteUri);
    

    The AbsoluteUri property includes the entire URI stored in the Uri instance, including all fragments and query strings.

提交回复
热议问题