Uri | CF 1.0, ECMA 1.0, serializable, marshal by reference |
This class encapsulates a
complete URI (Uniform Resource
Identifier) and provides various parts of it through properties. For
example, you can get the Scheme (e.g., http,
https, mailto) and the Port number. For http, the
default port is 80, if not specified in the Uri
(ftp uses port 21, https uses 443, and mailto uses 25). You can also
retrieve the query-string arguments—including the initial
question mark—from the Query property, or
the fragment portion—including the fragment marker
(#)—from the Fragment property. Some Boolean
properties include IsLoopback, which indicates
true if the Uri references the
local host, and IsUnc, which indicates
true if the Uri is a UNC path
(such as \\server\folder).
The Uri constructors perform some basic cleanup of
your parameters before creating a Uri, including
converting the scheme and hostname to lowercase, removing default and
blank port numbers, and removing the trailing slash (/). Instances of
Uri have read-only properties. To modify a
Uri, use a UriBuilder object.
The Uri class also provides static helper methods
such as EscapeString( ), which converts a string
to a valid URL by converting all characters with an ASCII value
greater than 127 to hexadecimal representation. The
CheckHostName( ) and CheckSchemeName(
) methods accept a string and check if it is syntactically
valid for the given property (although they do not attempt to
determine if a host or URI exists).
The Uri class is used by many .NET types,
including some in ASP.NET, although you may find many other uses for
it as a type-safe way to store and exchange URL information.
public class Uri : MarshalByRefObject , System.Runtime.Serialization.ISerializable {
// Public Constructors
public Uri(string uriString);
public Uri(string uriString, bool dontEscape);
public Uri(Uri baseUri, string relativeUri);
public Uri(Uri baseUri, string relativeUri, bool dontEscape);
// Protected Constructors
protected Uri(System.Runtime.Serialization.SerializationInfo serializationInfo,
System.Runtime.Serialization.StreamingContext streamingContext);
// Public Static Fields
public static readonly string SchemeDelimiter;
// =:/
public static readonly string UriSchemeFile;
// =file
public static readonly string UriSchemeFtp;
// =ftp
public static readonly string UriSchemeGopher;
// =gopher
public static readonly string UriSchemeHttp;
// =http
public static readonly string UriSchemeHttps;
// =https
public static readonly string UriSchemeMailto;
// =mailto
public static readonly string UriSchemeNews;
// =news
public static readonly string UriSchemeNntp;
// =nntp
// Public Instance Properties
public string AbsolutePath{get; }
public string AbsoluteUri{get; }
public string Authority{get; }
public string Fragment{get; }
public string Host{get; }
public UriHostNameType HostNameType{get; }
public bool IsDefaultPort{get; }
public bool IsFile{get; }
public bool IsLoopback{get; }
public bool IsUnc{get; }
public string LocalPath{get; }
public string PathAndQuery{get; }
public int Port{get; }
public string Query{get; }
public string Scheme{get; }
public string[ ] Segments{get; }
public bool UserEscaped{get; }
public string UserInfo{get; }
// Public Static Methods
public static UriHostNameType CheckHostName(string name);
public static bool CheckSchemeName(string schemeName);
public static int FromHex(char digit);
public static string HexEscape(char character);
public static char HexUnescape(string pattern, ref int index);
public static bool IsHexDigit(char character);
public static bool IsHexEncoding(string pattern, int index);
// Protected Static Methods
protected static string EscapeString(string str);
protected static bool IsExcludedCharacter(char character);
// Public Instance Methods
public override bool Equals(object comparand);
// overrides object
public override int GetHashCode( );
// overrides object
public string GetLeftPart(UriPartial part);
public string MakeRelative(Uri toUri);
public override string ToString( );
// overrides object
// Protected Instance Methods
protected virtual void Canonicalize( );
protected virtual void CheckSecurity( );
protected virtual void Escape( );
protected virtual bool IsBadFileSystemCharacter(char character);
protected virtual bool IsReservedCharacter(char character);
protected virtual void Parse( );
protected virtual string Unescape(string path);
}
Hierarchy
Object
MarshalByRefObject
Uri(System.Runtime.Serialization.ISerializable)
Returned By
System.Net.Cookie.CommentUri,
System.Net.HttpWebRequest.Address,
System.Net.IWebProxy.GetProxy( ),
System.Net.ServicePoint.Address,
System.Net.WebProxy.{Address, GetProxy(
)}, System.Net.WebRequest.RequestUri,
System.Net.WebResponse.ResponseUri,
UriBuilder.Uri,
System.Xml.XmlResolver.ResolveUri( )
Passed To
Multiple types
|