class Uri
Provides an object representation of a uniform resource identifier (URI) and easy access to the parts of the URI.
public Uri( string uriString )
Initializes a new instance of the class with the specified URI.
uriStringA string that identifies the resource to be represented by the instance. Note that an IPv6 address in string form must be enclosed within brackets. For example, "http://[2607:f8b0:400d:c06::69]".
public Uri( string uriString, bool dontEscape )
Initializes a new instance of the class with the specified URI, with explicit control of character escaping.
uriStringA string that identifies the resource to be represented by the instance. Note that an IPv6 address in string form must be enclosed within brackets. For example, "http://[2607:f8b0:400d:c06::69]".dontEscapeif is completely escaped; otherwise, .
public Uri( string uriString, UriKind uriKind )
Initializes a new instance of the class with the specified URI. This constructor allows you to specify if the URI string is a relative URI, absolute URI, or is indeterminate.
uriStringA string that identifies the resource to be represented by the instance. Note that an IPv6 address in string form must be enclosed within brackets. For example, "http://[2607:f8b0:400d:c06::69]".uriKindSpecifies whether the URI string is a relative URI, absolute URI, or is indeterminate.
public Uri( Uri baseUri, string relativeUri )
Initializes a new instance of the class based on the specified base URI and relative URI string.
baseUriThe base URI.relativeUriThe relative URI to add to the base URI.
public Uri( Uri baseUri, string relativeUri, bool dontEscape )
Initializes a new instance of the class based on the specified base and relative URIs, with explicit control of character escaping.
baseUriThe base URI.relativeUriThe relative URI to add to the base URI.dontEscapeif is completely escaped; otherwise, .
public Uri( Uri baseUri, Uri relativeUri )
Initializes a new instance of the class based on the combination of a specified base instance and a relative instance.
baseUriAn absolute that is the base for the new instance.relativeUriA relative instance that is combined with .
public string AbsolutePath { get; }
Gets the absolute path of the URI.
- Returns A containing the absolute path to the resource.
public string AbsoluteUri { get; }
Gets the absolute URI.
- Returns A containing the entire URI.
public string Authority { get; }
Gets the Domain Name System (DNS) host name or IP address and the port number for a server.
- Returns A containing the authority component of the URI represented by this instance.
public static UriHostNameType CheckHostName( string name )
Determines whether the specified host name is a valid DNS name.
nameThe host name to validate. This can be an IPv4 or IPv6 address or an Internet host name.- Returns A that indicates the type of the host name. If the type of the host name cannot be determined or if the host name is or a zero-length string, this method returns .
public static bool CheckSchemeName( string schemeName )
Determines whether the specified scheme name is valid.
schemeNameThe scheme name to validate.- Returns A value that is if the scheme name is valid; otherwise, .
public static int Compare( Uri uri1, Uri uri2, UriComponents partsToCompare, UriFormat compareFormat, StringComparison comparisonType )
Compares the specified parts of two URIs using the specified comparison rules.
uri1The first .uri2The second .partsToCompareA bitwise combination of the values that specifies the parts of and to compare.compareFormatOne of the values that specifies the character escaping used when the URI components are compared.comparisonTypeOne of the values.- Returns An value that indicates the lexical relationship between the compared components. Value Meaning Less than zero is less than . Zero equals . Greater than zero is greater than .
public string DnsSafeHost { get; }
Gets a host name that, after being unescaped if necessary, is safe to use for DNS resolution.
- Returns A that contains the host part of the URI in a format suitable for DNS resolution; or the original host string, if it is already suitable for resolution.
public bool Equals( object comparand )
Compares two instances for equality.
comparandThe instance or a URI identifier to compare with the current instance.- Returns A value that is if the two instances represent the same URI; otherwise, .
public static string EscapeDataString( string stringToEscape )
Converts a string to its escaped representation.
stringToEscapeThe string to escape.- Returns A that contains the escaped representation of .
public static string EscapeUriString( string stringToEscape )
Converts a URI string to its escaped representation.
stringToEscapeThe string to escape.- Returns A that contains the escaped representation of .
public string Fragment { get; }
Gets the escaped URI fragment.
- Returns A that contains any URI fragment information.
public static int FromHex( char digit )
Gets the decimal value of a hexadecimal digit.
digitThe hexadecimal digit (0-9, a-f, A-F) to convert.- Returns An value that contains a number from 0 to 15 that corresponds to the specified hexadecimal digit.
public string GetComponents( UriComponents components, UriFormat format )
Gets the specified components of the current instance using the specified escaping for special characters.
componentsA bitwise combination of the values that specifies which parts of the current instance to return to the caller.formatOne of the values that controls how special characters are escaped.- Returns A that contains the components.
public string GetLeftPart( UriPartial part )
Gets the specified portion of a instance.
partOne of the values that specifies the end of the URI portion to return.- Returns A that contains the specified portion of the instance.
public static string HexEscape( char character )
Converts a specified character into its hexadecimal equivalent.
characterThe character to convert to hexadecimal representation.- Returns The hexadecimal representation of the specified character.
public static char HexUnescape( string pattern, ref int index )
Converts a specified hexadecimal representation of a character to the character.
patternThe hexadecimal representation of a character.indexThe location in where the hexadecimal representation of a character begins.- Returns The character represented by the hexadecimal encoding at position . If the character at is not hexadecimal encoded, the character at is returned. The value of is incremented to point to the character following the one returned.
public string Host { get; }
Gets the host component of this instance.
- Returns A that contains the host name. This is usually the DNS host name or IP address of the server.
public UriHostNameType HostNameType { get; }
Gets the type of the host name specified in the URI.
- Returns A member of the enumeration.
public string IdnHost { get; }
The RFC 3490 compliant International Domain Name of the host, using Punycode as appropriate. This string, after being unescaped if necessary, is safe to use for DNS resolution.
- Returns The hostname, formatted with Punycode according to the IDN standard.
public bool IsAbsoluteUri { get; }
Gets whether the instance is absolute.
- Returns A value that is if the instance is absolute; otherwise, .
public bool IsBaseOf( Uri uri )
Determines whether the current instance is a base of the specified instance.
uriThe specified instance to test.- Returns if the current instance is a base of ; otherwise, .
public bool IsDefaultPort { get; }
Gets whether the port value of the URI is the default for this scheme.
- Returns A value that is if the value in the property is the default port for this scheme; otherwise, .
public bool IsFile { get; }
Gets a value indicating whether the specified is a file URI.
- Returns A value that is if the is a file URI; otherwise, .
public static bool IsHexDigit( char character )
Determines whether a specified character is a valid hexadecimal digit.
characterThe character to validate.- Returns if the character is a valid hexadecimal digit; otherwise, .
public static bool IsHexEncoding( string pattern, int index )
Determines whether a character in a string is hexadecimal encoded.
patternThe string to check.indexThe location in to check for hexadecimal encoding.- Returns A value that is if is hexadecimal encoded at the specified location; otherwise, .
public bool IsLoopback { get; }
Gets whether the specified references the local host.
- Returns A value that is if this references the local host; otherwise, .
public bool IsUnc { get; }
Gets whether the specified is a universal naming convention (UNC) path.
- Returns A value that is if the is a UNC path; otherwise, .
public static bool IsWellFormedUriString( string uriString, UriKind uriKind )
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.
uriStringThe string used to attempt to construct a .uriKindThe type of the in .- Returns if the string was well-formed; otherwise, .
public string LocalPath { get; }
Gets a local operating-system representation of a file name.
- Returns A that contains the local operating-system representation of a file name.
public string MakeRelative( Uri toUri )
Determines the difference between two instances.
toUriThe URI to compare to the current URI.- Returns If the hostname and scheme of this URI instance and are the same, then this method returns a that represents a relative URI that, when appended to the current URI instance, yields the parameter. If the hostname or scheme is different, then this method returns a that represents the parameter.
public Uri MakeRelativeUri( Uri uri )
Determines the difference between two instances.
uriThe URI to compare to the current URI.- Returns If the hostname and scheme of this URI instance and are the same, then this method returns a relative that, when appended to the current URI instance, yields . If the hostname or scheme is different, then this method returns a that represents the parameter.
public static bool op_Equality( Uri uri1, Uri uri2 )
Determines whether two instances have the same value.
uri1A instance to compare with .uri2A instance to compare with .- Returns A value that is if the instances are equivalent; otherwise, .
public static bool op_Inequality( Uri uri1, Uri uri2 )
Determines whether two instances do not have the same value.
uri1A instance to compare with .uri2A instance to compare with .- Returns A value that is if the two instances are not equal; otherwise, . If either parameter is , this method returns .
public string OriginalString { get; }
Gets the original URI string that was passed to the constructor.
- Returns A containing the exact URI specified when this instance was constructed; otherwise, .
public string PathAndQuery { get; }
Gets the and properties separated by a question mark (?).
- Returns A that contains the and properties separated by a question mark (?).
public int Port { get; }
Gets the port number of this URI.
- Returns An value that contains the port number for this URI.
public string Query { get; }
Gets any query information included in the specified URI.
- Returns A that contains any query information included in the specified URI.
public string Scheme { get; }
Gets the scheme name for this URI.
- Returns A that contains the scheme for this URI, converted to lowercase.
public static string SchemeDelimiter
Specifies the characters that separate the communication protocol scheme from the address portion of the URI. This field is read-only.
public string[] Segments { get; }
Gets an array containing the path segments that make up the specified URI.
- Returns A array that contains the path segments that make up the specified URI.
public static bool TryCreate( string uriString, UriKind uriKind, ref Uri result )
Creates a new using the specified instance and a .
uriStringThe representing the .uriKindThe type of the Uri.resultWhen this method returns, contains the constructed .- Returns A value that is if the was successfully created; otherwise, .
public static bool TryCreate( Uri baseUri, string relativeUri, ref Uri result )
Creates a new using the specified base and relative instances.
baseUriThe base .relativeUriThe relative , represented as a , to add to the base .resultWhen this method returns, contains a constructed from and . This parameter is passed uninitialized.- Returns A value that is if the was successfully created; otherwise, .
public static bool TryCreate( Uri baseUri, Uri relativeUri, ref Uri result )
Creates a new using the specified base and relative instances.
baseUriThe base .relativeUriThe relative to add to the base .resultWhen this method returns, contains a constructed from and . This parameter is passed uninitialized.- Returns A value that is if the was successfully created; otherwise, .
public static string UnescapeDataString( string stringToUnescape )
Converts a string to its unescaped representation.
stringToUnescapeThe string to unescape.- Returns A that contains the unescaped representation of .
public static string UriSchemeFile
Specifies that the URI is a pointer to a file. This field is read-only.
public static string UriSchemeFtp
Specifies that the URI is accessed through the File Transfer Protocol (FTP). This field is read-only.
public static string UriSchemeGopher
Specifies that the URI is accessed through the Gopher protocol. This field is read-only.
public static string UriSchemeHttp
Specifies that the URI is accessed through the Hypertext Transfer Protocol (HTTP). This field is read-only.
public static string UriSchemeHttps
Specifies that the URI is accessed through the Secure Hypertext Transfer Protocol (HTTPS). This field is read-only.
public static string UriSchemeMailto
Specifies that the URI is an email address and is accessed through the Simple Mail Transport Protocol (SMTP). This field is read-only.
public static string UriSchemeNetPipe
Specifies that the URI is accessed through the NetPipe scheme used by Windows Communication Foundation (WCF). This field is read-only.
public static string UriSchemeNetTcp
Specifies that the URI is accessed through the NetTcp scheme used by Windows Communication Foundation (WCF). This field is read-only.
public static string UriSchemeNews
Specifies that the URI is an Internet news group and is accessed through the Network News Transport Protocol (NNTP). This field is read-only.
public static string UriSchemeNntp
Specifies that the URI is an Internet news group and is accessed through the Network News Transport Protocol (NNTP). This field is read-only.
public bool UserEscaped { get; }
Indicates that the URI string was completely escaped before the instance was created.
- Returns A value that is if the parameter was set to when the instance was created; otherwise, .
public string UserInfo { get; }
Gets the user name, password, or other user-specific information associated with the specified URI.
- Returns A that contains the user information associated with the URI. The returned value does not include the '@' character reserved for delimiting the user information part of the URI.
public static string UriSchemeTelnet
😔 No documentation found.
public static string UriSchemeSsh
😔 No documentation found.
public static string UriSchemeWss
😔 No documentation found.
public static string UriSchemeWs
😔 No documentation found.
public bool IsWellFormedOriginalString( )
😔 No documentation found.
public static bool TryCreate( string uriString, ref UriCreationOptions creationOptions, ref Uri result )
😔 No documentation found.
public static string UnescapeDataString( ReadOnlySpan<char> charsToUnescape )
😔 No documentation found.
public static bool TryUnescapeDataString( ReadOnlySpan<char> charsToUnescape, Span<char> destination, ref int charsWritten )
😔 No documentation found.
public Uri( string uriString, ref UriCreationOptions creationOptions )
😔 No documentation found.
public int GetHashCode( )
😔 No documentation found.
public string ToString( )
😔 No documentation found.
public bool TryFormat( Span<char> destination, ref int charsWritten )
😔 No documentation found.
public Type GetType( )
😔 No documentation found.
public bool Equals( Uri other )
😔 No documentation found.
public static bool TryEscapeDataString( ReadOnlySpan<char> charsToEscape, Span<char> destination, ref int charsWritten )
😔 No documentation found.
public static string EscapeDataString( ReadOnlySpan<char> charsToEscape )
😔 No documentation found.
public static string UriSchemeFtps
😔 No documentation found.
public static string UriSchemeSftp
😔 No documentation found.