System.Uri Class

Namespace: System

Summary

Represents a Uniform Resource Identifier (URI) reference.

Constructors

Signature Description
Uri(string uriString) Initializes a new instance of the Uri class using the specified string.
Uri(string uriString, bool dontEscape) Initializes a new instance of the Uri class using the specified string and a value that indicates whether to escape the URI.
Uri(Uri baseUri, string relativeUri) Initializes a new instance of the Uri class using the specified base URI and relative URI.
Uri(Uri baseUri, string relativeUri, bool dontEscape) Initializes a new instance of the Uri class using the specified base URI, relative URI, and a value that indicates whether to escape the URI.

Properties

Name Type Description
AbsolutePath string Gets the absolute path to the resource.
AbsolutePathAndQuery string Gets the absolute path and query string.
Authority string Gets the Uniform Resource Identifier (URI) authority.
DnsSafeHost string Gets the DNS safe version of the host name.
Fragment string Gets the fragment identifier for the URI.
Host string Gets the host component of this URI.
IsAbsoluteUri bool Gets a value that indicates whether the URI is absolute.
IsDefaultPort bool Gets a value that indicates whether the URI uses the default port for its scheme.
IsFile bool Gets a value that indicates whether the URI is a file URI.
IsLoopback bool Gets a value that indicates whether the URI refers to a loopback address.
IsUnc bool Gets a value that indicates whether the URI is a Universal Naming Convention (UNC) path.
IsWellFormedUriString bool Gets a value that indicates whether the specified string is a valid Uniform Resource Identifier (URI).
IsZeroLength bool Gets a value that indicates whether the URI is zero length.
IsWellFormedUri bool Gets a value that indicates whether the URI is well-formed.
OriginalString string Gets the original string that was passed to the Uri constructor.
PathAndQuery string Gets the path and query string.
Port int Gets the port number of this URI.
Query string Gets the query string.
Scheme string Gets the scheme of this URI.
Segments string[] Gets the URI segments.
UserInfo string Gets the user information of this URI.

Methods

Signature Description
AbsoluteUri() Gets the absolute URI.
GetLeftPart(UriPartial part) Returns the specified component of the URI.
IsBaseOf(Uri uri) Determines whether the specified Uri is a base of the current Uri.
IsChildOf(Uri uri) Determines whether the current Uri is a child of the specified Uri.
IsWellFormedUri(string uriString, UriKind uriKind) Determines whether the specified string is a well-formed Uniform Resource Identifier (URI) of the specified kind.
MakeRelativeUri(Uri uri) Creates a relative URI from the current Uri to the specified Uri.
Parse(string uriString) Parses a Uniform Resource Identifier (URI) string and returns a Uri instance.
ToString() Returns the original string that was passed to the Uri constructor.
TryCreate(string uriString, out Uri result) Attempts to create a Uri instance from the specified string.
TryCreate(Uri baseUri, string relativeUri, out Uri result) Attempts to create a relative Uri instance from the specified base and relative Uri strings.

Fields

Name Type Description
UriSchemeFile string Represents the "file" URI scheme.
UriSchemeFtp string Represents the "ftp" URI scheme.
UriSchemeHttp string Represents the "http" URI scheme.
UriSchemeHttps string Represents the "https" URI scheme.
UriSchemeMailto string Represents the "mailto" URI scheme.
UriSchemeNews string Represents the "news" URI scheme.
UriSchemeNntp string Represents the "nntp" URI scheme.
UriSchemeSftp string Represents the "sftp" URI scheme.
UriSchemeTelnet string Represents the "telnet" URI scheme.
UriSchemeUrn string Represents the "urn" URI scheme.

See Also