asp.net.ph

Uri Class

System Namespace


Provides an object representation of a uniform resource indentifier ( URI ) and easy access to the parts of the URI.

Uri Class Members

Collapse   Constructors

Visibility Constructor Parameters
public Uri ( String uriString )
public Uri ( String uriString , Boolean dontEscape )
public Uri ( Uri baseUri , String relativeUri , Boolean dontEscape )
public Uri ( String uriString , UriKind uriKind )
public Uri ( Uri baseUri , String relativeUri )
public Uri ( Uri baseUri , Uri relativeUri )

Collapse   Fields

Visibility Name Type
public static SchemeDelimiter String
public static UriSchemeFile String
public static UriSchemeFtp String
public static UriSchemeGopher String
public static UriSchemeHttp String
public static UriSchemeHttps String
public static UriSchemeMailto String
public static UriSchemeNetPipe String
public static UriSchemeNetTcp String
public static UriSchemeNews String
public static UriSchemeNntp String

Collapse   Properties

Visibility Name Value Type Accessibility
public AbsolutePath String [ Get ]
public AbsoluteUri String [ Get ]
public Authority String [ Get ]
public DnsSafeHost String [ Get ]
public Fragment String [ Get ]
public Host String [ Get ]
public HostNameType UriHostNameType [ Get ]
public IdnHost String [ Get ]
public IsAbsoluteUri Boolean [ Get ]
public IsDefaultPort Boolean [ Get ]
public IsFile Boolean [ Get ]
public IsLoopback Boolean [ Get ]
public IsUnc Boolean [ Get ]
public LocalPath String [ Get ]
public OriginalString String [ Get ]
public PathAndQuery String [ Get ]
public Port Int32 [ Get ]
public Query String [ Get ]
public Scheme String [ Get ]
public Segments String [ Get ]
public UserEscaped Boolean [ Get ]
public UserInfo String [ Get ]

Collapse   Methods

Visibility Name Parameters Return Type
protected Canonicalize ( ) Void
public static CheckHostName ( String name ) UriHostNameType
public static CheckSchemeName ( String schemeName ) Boolean
protected CheckSecurity ( ) Void
public static Compare ( Uri uri1 , Uri uri2 , UriComponents partsToCompare , UriFormat compareFormat , StringComparison comparisonType ) Int32
public Equals ( Object comparand ) Boolean
protected Escape ( ) Void
public static EscapeDataString ( String stringToEscape ) String
protected static EscapeString ( String str ) String
public static EscapeUriString ( String stringToEscape ) String
public static FromHex ( Char digit ) Int32
public GetComponents ( UriComponents components , UriFormat format ) String
public GetHashCode ( ) Int32
public GetLeftPart ( UriPartial part ) String
protected GetObjectData ( SerializationInfo serializationInfo , StreamingContext streamingContext ) Void
public static HexEscape ( Char character ) String
public static HexUnescape ( String pattern , Int32& index ) Char
protected IsBadFileSystemCharacter ( Char character ) Boolean
public IsBaseOf ( Uri uri ) Boolean
protected static IsExcludedCharacter ( Char character ) Boolean
public static IsHexDigit ( Char character ) Boolean
public static IsHexEncoding ( String pattern , Int32 index ) Boolean
protected IsReservedCharacter ( Char character ) Boolean
public IsWellFormedOriginalString ( ) Boolean
public static IsWellFormedUriString ( String uriString , UriKind uriKind ) Boolean
public MakeRelative ( Uri toUri ) String
public MakeRelativeUri ( Uri uri ) Uri
protected Parse ( ) Void
public ToString ( ) String
public static TryCreate ( Uri baseUri , String relativeUri , Uri& result ) Boolean
public static TryCreate ( Uri baseUri , Uri relativeUri , Uri& result ) Boolean
public static TryCreate ( String uriString , UriKind uriKind , Uri& result ) Boolean
protected Unescape ( String path ) String
public static UnescapeDataString ( String stringToUnescape ) String

Remarks

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.aspx" ). Relative URIs ( for example, "/new/index.aspx" ) 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.

  • Converts the URI scheme to lower case.
  • Converts the host name to lower case.
  • Removes default and empty port numbers.
  • Simplifies the URI by removing superfluous segments such as "/" and "/test" segments.

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.

Example

The following example creates an instance of the Uri class and uses it to create a WebRequest.

[ VB ]
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 );

See Also

UriBuilder Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph