Uri Class
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Provides an object representation of a uniform resource identifier (URI) and easy access to the parts of the URI.
Inheritance Hierarchy
System. . :: . .Object
System..::..Uri
Namespace: System
Assembly: System.Http (in System.Http.dll)
Syntax
'Declaration
Public Class Uri
public class Uri
public ref class Uri
type Uri = class end
public class Uri
The Uri type exposes the following members.
Constructors
Name | Description | |
---|---|---|
Uri(String) | Initializes a new instance of the Uri class with the specified URI. | |
Uri(String, UriKind) | Initializes a new instance of the Uri class with the specified URI. This constructor allows you to specify if the URI string is a relative URI, absolute URI, or is indeterminate. |
Top
Properties
Name | Description | |
---|---|---|
AbsolutePath | Gets the absolute path of the URI. | |
AbsoluteUri | Gets the absolute URI. | |
Host | Gets the host component of this instance. | |
HostNameType | Gets the type of the host name specified in the URI. | |
IsAbsoluteUri | Gets whether the Uri instance is absolute. | |
IsLoopback | Gets whether the specified Uri references the local host. | |
IsUnc | Gets whether the specified Uri is a universal naming convention (UNC) path. | |
OriginalString | Gets the original URI string that was passed to the Uri constructor. | |
Port | Gets the port number of this URI. | |
Scheme | Gets the scheme name for this URI. |
Top
Methods
Name | Description | |
---|---|---|
ConstructAbsoluteUri | Constructs an absolute Uri from a URI string. | |
Equals | Compares two Uri instances for equality. (Overrides Object. . :: . .Equals(Object).) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Gets the hash code for the URI. (Overrides Object. . :: . .GetHashCode() () () ().) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
IsAlpha | Determines whehter the character value is an alpha character. | |
IsAlphaNumeric | Determines whether the character is an alpha or numeric. | |
IsHex | Determines whether the value is hexadecimal. | |
IsIPv4 | Determines whether the host name is an IP address 4 bytes, such as 192.1.1.1. | |
IsWellFormedUriString | Indicates whether the string is well-formed by attempting to construct a URI with the string and ensures that the string does not require further escaping. | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ParseUriString | Parses a URI string into Uri variables. | |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
ValidateRelativePath | Parses relative Uri into variables. | |
ValidateUriPart | Validates that part of Uri after scheme is valid for an unknown Uri scheme. | |
ValidateUrn | Parses urn string into Uri variables. |
Top
Operators
Name | Description | |
---|---|---|
Equality | Determines whether two Uri instances have the same value. | |
Inequality | Determines whether two Uri instances do not have the same value. |
Top
Fields
Name | Description | |
---|---|---|
HttpDefaultPort | Contains the default port for http protocol. The value is set to 80. | |
HttpsDefaultPort | Contains the default port for https protocol. The value is set to 443. | |
m_AbsolutePath | Contains the absolute path of the URI. | |
m_Flags | Contains the internal flags. | |
m_host | Contains ttthe host name (http and https). | |
m_hostNameType | Contains the type of the host. | |
m_isAbsoluteUri | Contains the absolute URI. | |
m_isUnc | Contains a value that indicates whether the specified Uri is a universal naming convention (UNC) path. | |
m_OriginalUriString | Contains the original URI string that was passed to the Uri constructor. | |
m_port | Contains the port number of this URI. | |
m_scheme | Contains the scheme name for this URI. | |
UnknownPort | Contains a value used to indicate the port for this protocol is unknown. |
Top
Remarks
A URI is a compact representation of a resource available to your application on the intranet or Internet. The Uri class defines the properties and methods for handling URIs, including parsing, comparing, and combining.
The Uri constructors do not escape URI strings if the string is a well-formed URI including a scheme identifier.
The Uri properties return a canonical data representation in escaped encoding, with all characters with Unicode values greater than 127 replaced with their hexadecimal equivalents. To put the URI in canonical form, the Uri constructor performs the following steps:
Converts the URI scheme to lowercase.
Converts the host name to lowercase.
If the host name is an IPv6 address, the canonical IPv6 address is used. ScopeId and other optional IPv6 data are removed.
Removes default and empty port numbers.
Canonicalizes the path for hierarchical URIs by compacting sequences such as /./, /../, //, including escaped representations. Note that there are some schemes for which escaped representations are not compacted.
For hierarchical URIs, if the host is not terminated with a forward slash (/), one is added.
By default, any reserved characters in the URI are escaped in accordance with RFC 2396. This behavior changes if International Resource Identifiers or International Domain Name parsing is enabled in which case reserved characters in the URI are escaped in accordance with RFC 3986 and RFC 3987.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.