This topic has not yet been rated - Rate this topic

Uri Constructor (String)

April 12, 2014

Initializes a new instance of the Uri class with the specified URI.

Namespace:  System
Assembly:  System (in System.dll)
public Uri(
	string uriString
)

Parameters

uriString
Type: System.String
A URI.
ExceptionCondition
ArgumentNullException

uriString is null.

UriFormatException

uriString is empty.

-or-

The scheme specified in uriString is not correctly formed. See CheckSchemeName.

-or-

uriString contains too many slashes.

-or-

The password specified in uriString is not valid.

-or-

The host name specified in uriString is not valid.

-or-

The file name specified in uriString is not valid.

-or-

The user name specified in uriString is not valid.

-or-

The host or authority name specified in uriString cannot be terminated by backslashes.

-or-

The port number specified in uriString is not valid or cannot be parsed.

-or-

The length of uriString exceeds 65519 characters.

-or-

The length of the scheme specified in uriString exceeds 1024 characters.

-or-

There is an invalid character sequence in uriString.

-or-

The MS-DOS path specified in uriString must start with c:\\.

This constructor creates a Uri instance from a URI string. It parses the URI, puts it in canonical format, and makes any required escape encodings.

This constructor assumes that the string parameter references an absolute URI and is equivalent to calling the Uri constructor with UriKind set to Absolute. If the string parameter passed to the constructor is a relative URI, this constructor will throw a UriFormatException.

The uriString can be poorly formed and can still be used to construct a Uri instance. The Windows Phone runtime will try to correct some minor issues with a poorly-formed string when this constructor is called to create a Uri instance.

This constructor allows a Windows Phone application to create a Uri instance for many schemes as described in the Scheme property. However, only Uri instances for the UriSchemeHttp or UriSchemeHttps schemes are supported by the WebClient and HTTP classes in the System.Net namespace.

This constructor does not ensure that the Uri refers to an accessible resource.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.