Uri class

Expand
This topic has not yet been rated - Rate this topic

Uri class

[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.

ConstructorDescription
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.

MethodDescription
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.

PropertyAccess typeDescription

AbsoluteUri

Read-onlyGets the entire canonicalized Uniform Resource Identifier (URI).

DisplayUri

Read-onlyGets a representation of the Uniform Resource Identifier (URI) that can be used for display purposes.

Domain

Read-onlyGets the domain name, including top-level domain, from a Uniform Resource Identifier (URI).

Extension

Read-onlyGets the file name extension of the resource that is referenced in the Uniform Resource Identifier (URI).

Fragment

Read-onlyGets the text following a fragment marker (#), including the fragment marker itself.

Host

Read-onlyGets the fully qualified domain name.

Password

Read-onlyGets the password, as parsed from a Uniform Resource Identifier (URI).

Path

Read-onlyGets the path and resource name.

Port

Read-onlyGets the port number.

Query

Read-onlyGets the query string.

QueryParsed

Read-onlyGets a parsed URL query string.

RawUri

Read-onlyGets the entire original Uniform Resource Identifier (URI) string.

SchemeName

Read-onlyGets the protocol scheme name.

Suspicious

Read-onlyGets a value that indicates whether the Uniform Resource Identifier (URI) is not well-formed.

UserName

Read-onlyGets 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

Windows.Foundation
Windows::Foundation [C++]

Metadata

Windows.winmd

See also

How to reference content

 

 

Build date: 5/22/2012

Did you find this helpful?
(1500 characters remaining)
Community Additions ADD