Uri class
Parses Uniform Resource Identifiers (URIs).
.NET: This type appears as System.Uri.
Syntax
var uri = new Windows.Foundation.Uri(string); var uri = new Windows.Foundation.Uri(string, string);
Attributes
- ActivatableAttribute(Windows.Foundation.IUriRuntimeClassFactory, NTDDI_WIN8)
- DualApiPartitionAttribute()
- MarshalingBehaviorAttribute(Agile)
- StaticAttribute(Windows.Foundation.IUriEscapeStatics, NTDDI_WIN8)
- ThreadingAttribute(Both)
- VersionAttribute(NTDDI_WIN8)
Members
The Uri class has these types of members:
Constructors
The Uri class has these constructors.
| Constructor | Description |
|---|---|
| Uri(String) | Creates a Uniform Resource Identifier (URI) from the specified string. |
| Uri(String, String) | Creates a Uniform Resource Identifier (URI) by combining a base Uniform Resource Identifier (URI) and a relative Uniform Resource Identifier (URI). |
Methods
The Uri class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
| Method | Description |
|---|---|
| CombineUri | Adds the specified Uniform Resource Identifier (URI) to the current Uniform Resource Identifier (URI). |
| Equals(Uri) | Determines whether the specified Uniform Resource Identifier (URI) is equal to the current Uniform Resource Identifier (URI). |
| EscapeComponent | Converts a URI string to its escaped representation. |
| UnescapeComponent | Converts the specified string by replacing any escape sequences with their unescaped representation. |
Properties
The Uri class has these properties.
| Property | Access type | Description |
|---|---|---|
| Read-only | Gets a fully canonicalized RFC-complaint representation of the current URI. | |
| Read-only | Gets the entire, non-canonical IRI. | |
| Read-only | Gets the decoded unicode characters that make up the current URI. | |
| Read-only | Gets a representation of the IRI that can be used for display purposes. | |
| Read-only | Gets the domain name, including top-level domain, from a Uniform Resource Identifier (URI). | |
| Read-only | Gets the file name extension of the resource that is referenced in the Uniform Resource Identifier (URI). | |
| Read-only | Gets the text following a fragment marker (#), including the fragment marker itself. | |
| Read-only | Gets the fully qualified domain name. | |
| Read-only | Gets the password, as parsed from a Uniform Resource Identifier (URI). | |
| Read-only | Gets the path and resource name. | |
| Read-only | Gets the port number. | |
| Read-only | Gets the query string. | |
| Read-only | Gets a parsed URL query string. | |
| Read-only | Gets the entire original Uniform Resource Identifier (URI) string. | |
| Read-only | Gets the protocol scheme name. | |
| Read-only | Gets a value that indicates whether the Uniform Resource Identifier (URI) is not well-formed. | |
| Read-only | Gets the user name as parsed from a Uniform Resource Identifier (URI). |
Remarks
When building Windows Store apps with the Microsoft .NET Framework, this class is hidden and developers should use the System.Uri class, which uses RFC 3987 to encode and decode URIs. The Uri class doesn't percent-encode non-ASCII characters in file:// URIs and interprets percent-encoding using the user's current codepage.
Here is a breakdown of the parts of an example URI:
scheme://username:password@host:port/path.extension?query#fragment
For example:
ftp://user:password@ftp.microsoft.com:8080/path/bin/file.asp?q=query#fragment
In this example:
- scheme is ftp
- host is ftp.microsoft.com
- domain is microsoft.com (a subset of host)
- port is 8080
- extension is asp
Examples
This example creates a URI that uses the http protocol to access a website.
// The URI string var uriToLaunch = "http://www.bing.com"; // Create a Uri object from the URI string var uri = new Windows.Foundation.Uri(uriToLaunch);
This example creates a URI that uses the ms-appx protocol to access an image file in the app package.
// The URI string var uriImage = "ms-appx:///images/SecondaryTileDefault-sdk.png"; // Create a Uri object from the URI string var uri = new Windows.Foundation.Uri(uriImage);
This example creates a URI that uses the ms-appdata protocol to access a file in local app data store for your app.
// The URI string var uriFile = "ms-appdata:///local/file.ext"; // Create a Uri object from the URI string var uri = new Windows.Foundation.Uri(uriFile);
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps, desktop apps] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps, desktop apps] |
|
Minimum supported phone | Windows Phone 8 |
|
Namespace |
|
|
Metadata |
|
See also
Build date: 2/25/2013
