[This documentation is preliminary and is subject to change.]
Applies to: Metro style apps | desktop apps
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)
- 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). |
Properties
The Uri class has these properties.
| Property | Access type | Description |
|---|---|---|
| Read-only | Gets the entire canonicalized Uniform Resource Identifier (URI). | |
| Read-only | Gets a representation of the Uniform Resource Identifier (URI) 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
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 Release Preview |
|---|---|
|
Minimum supported server | Windows Server 2012 |
|
Namespace |
|
|
Metadata |
|
See also
Build date: 5/22/2012
