Provides an object representation of a uniform resource identifier (URI) and easy access to the parts of the URI.
For a list of all members of this type, see Uri Members.
System.Object
System.MarshalByRefObject
System.Uri
[Visual Basic] <Serializable> Public Class Uri Inherits MarshalByRefObject Implements ISerializable [C#] [Serializable] public class Uri : MarshalByRefObject, ISerializable [C++] [Serializable] public __gc class Uri : public MarshalByRefObject, ISerializable [JScript] public Serializable class Uri extends MarshalByRefObject implements ISerializable
Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.
A URI is a compact representation of a resource available to your application on the Internet. The Uri class defines the properties and methods for handling URIs, including parsing, comparing, and combining. The Uri class properties are read-only, to modify a Uri instance use the UriBuilder class.
The Uri class stores only absolute URIs (for example, "http://www.contoso.com/index.htm"). Relative URIs (for example, "/new/index.htm") must be expanded with respect to a base URI so that they are absolute. The MakeRelative method is provided to convert absolute URIs to relative URIs when necessary.
The Uri constructors will not escape URI strings if the string is a well-formed URI including a scheme identifier that contains escape sequences. The constructors will escape relative URI strings that contain a percent sign (%).
URIs are stored as canonical URIs in escaped encoding, with all characters with ASCII values greater than 127 replaced with their hexidecimal equivalents. To put the URI in canonical form, the Uri constructor performs the following steps.
You can transform the contents of the Uri class from an escape encoded URI reference to a readable URI reference using the ToString method.
Some URIs include a fragment identifier or query. A fragment identifier is any text that follows a number sign (#) in the URI and is stored in the Fragment property. Query information is any text that follows a question mark (?) in the URI, and is stored in the Query property.
Note The URI class supports the use of IP addresses in both quad-notation for IPv4 protocol and colon-hexadecimal for IPv6 protocol. Remember to enclose the IPv6 address in square brackets, as in http://[::1].
.NET Compact Framework - Windows CE .NET Platform Note: Some device file systems do not support relative paths. Specify absolute path information.
[Visual Basic, C#, JScript] The following example creates an instance of the Uri class and uses it to create a WebRequest.
[Visual Basic] Dim siteUri As New Uri("http://www.contoso.com/") Dim wr As WebRequest = WebRequest.Create(siteUri) [C#] Uri siteUri = new Uri("http://www.contoso.com/"); WebRequest wr = WebRequest.Create(siteUri); [JScript] var siteUri : Uri = new Uri("http://www.contoso.com/"); var wr : WebRequest = WebRequest.Create(siteUri);
[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button
in the upper-left corner of the page.
Namespace: System
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework - Windows CE .NET
Assembly: System (in System.dll)