Uri Constructor (Uri, String, Boolean)

NOTE: This API is now obsolete.

Initializes a new instance of the Uri class based on the specified base and relative URIs, with explicit control of character escaping.

Namespace:  System
Assembly:  System (in System.dll)

[ObsoleteAttribute("The constructor has been deprecated. Please new Uri(Uri, string). The dontEscape parameter is deprecated and is always false. http://go.microsoft.com/fwlink/?linkid=14202")]
public Uri(
	Uri baseUri,
	string relativeUri,
	bool dontEscape
)

Parameters

baseUri
Type: System.Uri

The base URI.

relativeUri
Type: System.String

The relative URI to add to the base URI.

dontEscape
Type: System.Boolean

true if uriString is completely escaped; otherwise, false. See Remarks.

ExceptionCondition
ArgumentNullException

uriString is null.

ArgumentOutOfRangeException

baseUri is not an absolute Uri instance.

UriFormatException

The URI formed by combining baseUri and relativeUri is empty or contains only spaces.

-or-

The scheme specified in the URI formed by combining baseUri and relativeUri is not valid.

-or-

The URI formed by combining baseUri and relativeUri contains too many slashes.

-or-

The password specified in the URI formed by combining baseUri and relativeUri is not valid.

-or-

The host name specified in the URI formed by combining baseUri and relativeUri is not valid.

-or-

The file name specified in the URI formed by combining baseUri and relativeUri is not valid.

-or-

The user name specified in the URI formed by combining baseUri and relativeUri is not valid.

-or-

The host or authority name specified in the URI formed by combining baseUri and relativeUri cannot be terminated by backslashes.

-or-

The port number specified in the URI formed by combining baseUri and relativeUri is not valid or cannot be parsed.

-or-

The length of the URI formed by combining baseUri and relativeUri exceeds 65519 characters.

-or-

The length of the scheme specified in the URI formed by combining baseUri and relativeUri exceeds 1023 characters.

-or-

There is an invalid character sequence in the URI formed by combining baseUri and relativeUri.

-or-

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

This constructor creates a Uri instance by combining baseUri and relativeUri. If the URI passed in relativeUri is an absolute URI (containing a scheme, host name, and optionally a port number), the Uri instance is created using only relativeUri.

The dontEscape parameter controls whether reserved characters are translated into escape sequences. This parameter should be set to true only if you are certain that all reserved characters in the URI have been escaped. Setting the value to true for a URI that has not been completely escaped can cause unexpected behavior. It is strongly recommended that you always set this parameter to false. If dontEscape is set to false, the constructor escapes any reserved characters by checking that all occurrences of percent (%) are followed by a valid escape sequence. If the character sequence following a percent is not valid, the percent is replaced by %25.

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

Notes to Callers:

Because of security concerns, your application should not call this constructor with URI strings from untrusted sources and with dontEscape set to true. Alternately, you can check a URI string for validity by calling the IsWellFormedOriginalString method prior to calling this constructor.

The following example creates a new instance of the Uri class by combining the relative URIs http://www.contoso.com and Hello%20World.htm to form an absolute URI.

Uri baseUri = new Uri("http://www.contoso.com");
Uri myUri = new Uri(baseUri, "Hello%20World.htm",false);
	Uri* baseUri = new Uri(S"http://www.contoso.com/");
	Uri* myUri = new Uri(baseUri,S"Hello%20World.htm", false);

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 1.1, 1.0
Obsolete (compiler warning) in 3.5
Obsolete (compiler warning) in 3.5 SP1
Obsolete (compiler warning) in 3.0
Obsolete (compiler warning) in 3.0 SP1
Obsolete (compiler warning) in 3.0 SP2
Obsolete (compiler warning) in 2.0
Obsolete (compiler warning) in 2.0 SP1
Obsolete (compiler warning) in 2.0 SP2

.NET Compact Framework

Supported in: 1.0
Obsolete (compiler warning) in 3.5
Obsolete (compiler warning) in 2.0

XNA Framework

Obsolete (compiler warning) in 3.0
Obsolete (compiler warning) in 2.0
Obsolete (compiler warning) in 1.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft