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().
Is there a reason for this? The documentation for Uri.AbsoluteUri
notes that it "Gets the absolute URI", Uri.ToString()
"Gets a canonical string representation for the specified instance."
The AbsoluteUri property includes the entire URI stored in the Uri instance, including all fragments and query strings.
The AbsolutePath property contains the path information that the server uses to resolve requests for information. Typically this is the path to the desired information on the server's file system, although it also can indicate the application or script the server must run to provide the information.
A URI is a compact representation of a resource available to your application on the intranet or internet. The Uri class defines the properties and methods for handling URIs, including parsing, comparing, and combining. The Uri class properties are read-only; to create a modifiable object, use the UriBuilder class.
Given for example:
UriBuilder builder = new UriBuilder("http://somehost/somepath"); builder.Query = "somekey=" + HttpUtility.UrlEncode("some+value"); Uri someUri = builder.Uri;
In this case, Uri.ToString()
will return a human-readable URL: http://somehost/somepath?somekey=some+value
Uri.AbsoluteUri
on the other hand will return the encoded form as HttpUtility.UrlEncode returned it: http://somehost/somepath?somekey=some%2bvalue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With