Uri Uri Uri Uri Class

定義

提供統一資源識別元 (URI) 的物件表示,以及對 URI 各部分的簡易存取。Provides an object representation of a uniform resource identifier (URI) and easy access to the parts of the URI.

public ref class Uri : System::Runtime::Serialization::ISerializable
[System.ComponentModel.TypeConverter(typeof(System.UriTypeConverter))]
[System.Serializable]
public class Uri : System.Runtime.Serialization.ISerializable
type Uri = class
    interface ISerializable
Public Class Uri
Implements ISerializable
繼承
屬性
實作

範例

下列範例建立的執行個體Uri類別,並使用它來建立WebRequest執行個體。The following example creates an instance of the Uri class and uses it to create a WebRequest instance.

Uri^ siteUri = gcnew Uri( "http://www.contoso.com/" );
WebRequest^ wr = WebRequest::Create( siteUri );
Uri siteUri = new Uri("http://www.contoso.com/");
 
WebRequest wr = WebRequest.Create(siteUri);

Dim siteUri As New Uri("http://www.contoso.com/")
        
Dim wr As WebRequest = WebRequest.Create(siteUri)

備註

URI 是精簡的方式,可以使用您的應用程式,在內部網路或網際網路上的資源。A URI is a compact representation of a resource available to your application on the intranet or Internet. Uri類別定義的屬性和方法來處理包括剖析、 比較和結合的 Uri。The Uri class defines the properties and methods for handling URIs, including parsing, comparing, and combining. Uri類別屬性是唯讀; 若要建立可修改的物件,使用UriBuilder類別。The Uri class properties are read-only; to create a modifiable object, use the UriBuilder class.

相對 Uri (例如,"/ new/index.htm"),使其絕對必須展開相關的基底 URI。Relative URIs (for example, "/new/index.htm") must be expanded with respect to a base URI so that they are absolute. MakeRelative方法提供來轉換時所需的相對 Uri 的絕對 Uri。The MakeRelative method is provided to convert absolute URIs to relative URIs when necessary.

Uri建構函式不會逸出 URI 字串的字串是否格式正確的 URI,包括結構描述識別碼。The Uri constructors do not escape URI strings if the string is a well-formed URI including a scheme identifier.

Uri屬性傳回的標準資料表示法中逸出的編碼,所有字元都使用 Unicode 值大於 127,其十六進位對等項目所取代。The Uri properties return a canonical data representation in escaped encoding, with all characters with Unicode values greater than 127 replaced with their hexadecimal equivalents. 若要以標準的形式,放入 URIUri建構函式會執行下列步驟:To put the URI in canonical form, the Uri constructor performs the following steps:

  • 轉換為小寫的 URI 配置。Converts the URI scheme to lowercase.

  • 將主機名稱轉換成小寫。Converts the host name to lowercase.

  • 如果主機名稱是 IPv6 位址,則會使用標準的 IPv6 位址。If the host name is an IPv6 address, the canonical IPv6 address is used. ScopeId 和其他選用的 IPv6 資料被移除。ScopeId and other optional IPv6 data are removed.

  • 移除預設值和空白的連接埠號碼。Removes default and empty port numbers.

  • 將隱含的檔案路徑,而不需要 file:// scheme (比方說,「 C:\my\file") 轉換成使用 file:// scheme 的明確的檔案路徑。Converts implicit file paths without the file:// scheme (for example, "C:\my\file") to explicit file paths with the file:// scheme.

  • 沒有保留的用途的逸出的字元 (也就是百分比編碼的八位元組) 會解碼 (也就是需要取消逸出)。Escaped characters (also known as percent-encoded octets) that don't have a reserved purpose are decoded (also known as being unescaped). 這些非保留的字元包括大寫和小寫字母 (%41-%5a 和 %61-%7a)、 小數位數 (%30-%39)、 連字號 (%2d),期間 (%2e)、 底線 (%5f),以及波狀符號 (%7e)。These unreserved characters include uppercase and lowercase letters (%41-%5A and %61-%7A), decimal digits (%30-%39), hyphen (%2D), period (%2E), underscore (%5F), and tilde (%7E).

  • Canonicalizes 路徑為階層式 Uri 以壓縮的序列例如 /。 /.../,,/ / (是否序列逸出)。Canonicalizes the path for hierarchical URIs by compacting sequences such as /./, /../, and // (whether or not the sequence is escaped). 請注意,某些配置中,這些序列則不會壓縮。Note that there are some schemes for which these sequences are not compacted.

  • 階層式 uri,如果主機不以正斜線 (/),以終止會新增一個。For hierarchical URIs, if the host is not terminated with a forward slash (/), one is added.

  • 根據預設,任何在 URI 中的保留的字元會根據 RFC 2396 逸出。By default, any reserved characters in the URI are escaped in accordance with RFC 2396. 此行為的變更如果啟用國際資源識別項或國際網域名稱解析在 URI 中哪些案例保留字元會逸出根據 RFC 3986 和 RFC 3987。This behavior changes if International Resource Identifiers or International Domain Name parsing is enabled in which case reserved characters in the URI are escaped in accordance with RFC 3986 and RFC 3987.

在某些配置、 點區段和空的區段的建構函式的標準化的一部分 (/。 /.../,,/ /) 壓縮的 (也就是說,它們會移除)。As part of canonicalization in the constructor for some schemes, dot-segments and empty segments (/./, /../, and //) are compacted (in other words, they are removed). 配置的 URI 會將壓縮這些序列包括 http、 https、 tcp、 net.pipe 和 net.tcp。The schemes for which URI will compact these sequences include http, https, tcp, net.pipe, and net.tcp. 對於其他配置,這些序列則不會壓縮。For some other schemes, these sequences are not compacted. 以下是此壓縮外觀實務。Here's how this compacting looks in practice.

var uri = new Uri("http://myUrl/../.."); // http scheme, unescaped
OR
var uri = new Uri("http://myUrl/%2E%2E/%2E%2E"); // http scheme, escaped
OR
var uri = new Uri("ftp://myUrl/../.."); // ftp scheme, unescaped
OR
var uri = new Uri("ftp://myUrl/%2E%2E/%2E%2E"); // ftp scheme, escaped

Console.WriteLine(uri.AbsoluteUri);  
Console.WriteLine(uri.PathAndQuery);  

執行此程式碼時,它會傳回下列輸出,以視需要取消逸出,然後壓縮的逸出序列。When this code is executed, it returns the following output, with the escaped sequences unescaped if necessary and then compacted.

http://myUrl/  
/  

您可以將轉換的內容Uri類別可讀取的 URI 參考,使用編碼的逸出 URI 參考ToString方法。You can transform the contents of the Uri class from an escape encoded URI reference to a readable URI reference by using the ToString method. 請注意,可能仍某些保留的字元逸出的輸出中ToString方法。Note that some reserved characters might still be escaped in the output of the ToString method. 這是為了支援的 URI 所傳回的值從模稜兩可的重新建構ToStringThis is to support unambiguous reconstruction of a URI from the value returned by ToString.

一些 Uri 包含片段識別項、 查詢或兩者。Some URIs include a fragment identifier or a query or both. 片段識別項是任何文字,會遵循數字符號 (#),不包括數字的符號;片段文字儲存在Fragment屬性。A fragment identifier is any text that follows a number sign (#), not including the number sign; the fragment text is stored in the Fragment property. 查詢資訊就會遵循問號 (?) 的 URI; 中的任何文字查詢文字會儲存在Query屬性。Query information is any text that follows a question mark (?) in the URI; the query text is stored in the Query property.

在.NET Framework 版本 1.1 中,如果建構函式所指定的字串包含未知的配置和"c:\",Uri 類別插入"/ /"冒號後面。In the .NET Framework version 1.1, if the string specified to a constructor contains an unknown scheme and "c:\", the Uri class inserts "//" after the colon. 例如,URIxyz:c:\abc轉換成xyz://c:/abcFor example, the URI xyz:c:\abc is converted to xyz://c:/abc. 在.NET Framework 2.0 版中,已移除這種行為,而字串範例會轉換成xyz:c:/abcIn the .NET Framework version 2.0, this behavior has been removed, and the example string is converted to xyz:c:/abc.

注意

URI 類別支援 IPv4 通訊協定的兩個四組數字標記法和冒號-十六進位 IPv6 通訊協定使用的 IP 位址。The URI class supports the use of IP addresses in both quad-notation for IPv4 protocol and colon-hexadecimal for IPv6 protocol. 請記得將 IPv6 位址括在方括號,如同 http://[::1]。Remember to enclose the IPv6 address in square brackets, as in http://[::1].

國際資源識別項支援International Resource Identifier Support

網址通常是使用一組非常有限的字元所組成的統一資源識別元來表示:Web addresses are typically expressed using uniform resource identifiers that consist of a very restricted set of characters:

  • 大寫和小寫的英文 ASCII 字母。Upper and lower case ASCII letters from the English alphabet.

  • 0 到 9 位數。Digits from 0 to 9.

  • 少數幾個其他 ASCII 符號。A small number of other ASCII symbols.

Uri 的規格記載於 RFC 2396、 RFC 2732、 RFC 3986 和 RFC 3987 發佈由 Internet Engineering Task Force (IETF)。The specifications for URIs are documented in RFC 2396, RFC 2732, RFC 3986, and RFC 3987 published by the Internet Engineering Task Force (IETF).

隨著網際網路的成長,識別使用非英文語言資源的需求也持續成長。With the growth of the Internet, there is a growing need to identify resources using languages other than English. 有利此需求且允許非 ASCII 字元 (Unicode/ISO 10646 字元集中的字元) 的識別碼,稱為國際資源識別碼 (IRI)。Identifiers which facilitate this need and allow non-ASCII characters (characters in the Unicode/ISO 10646 character set) are known as International Resource Identifiers (IRIs). IETF 發行的 RFC 3987 中有記載 IRI 的規格。The specifications for IRIs are documented in RFC 3987 published by IETF. 使用 IRI 可讓 URL 包含 Unicode 字元。Using IRIs allows a URL to contain Unicode characters.

現有Uri類別已經過擴充,在.NET Framework 3.5 版,3.0 SP1 和 2.0 SP1 提供 IRI 支援根據 RFC 3987。The existing Uri class has been extended in .NET Framework v3.5, 3.0 SP1, and 2.0 SP1 to provide IRI support based on RFC 3987. 4.5 版之前的.NET Framework 版本的使用者不會看到任何變更從.NET Framework 2.0 的行為,除非它們特別啟用 IRI。Users of .NET Framework versions before version 4.5 will not see any change from the .NET Framework 2.0 behavior unless they specifically enable IRI. 這可確保應用程式與舊版 .NET framework 相容。This ensures application compatibility with prior versions of the .NET Framework.

若要啟用 IRI 支援,下列變更是必要的:To enable support for IRI, the following change is required:

  • 指定是否要國際化網域名稱 (IDN) 剖析套用至網域名稱以及是否應該套用 IRI 剖析規則。Specify whether you want Internationalized Domain Name (IDN) parsing applied to the domain name and whether IRI parsing rules should be applied. 這可以machine.config或是在app.config檔案。This can be done in the machine.config or in the app.config file. 例如,新增下列內容:For example, add the following:

    <configuration>  
      <uri>  
      <idn enabled="All" />  
      <iriParsing enabled="true" />  
      </uri>  
    </configuration>  
    

.NET Framework 4.5 及更新版本的使用者永遠都有啟用 IRI。Users of .NET Framework 4.5 and newer always have IRI enabled. IRI 剖析無法使用變更 .config檔案。IRI parsing cannot be changed using a .config file.

啟用 IDN 會將網域名稱中所有的 Unicode 標籤轉換成對等的 Punycode。Enabling IDN will convert all Unicode labels in a domain name to their Punycode equivalents. Punycode 名稱只包含 ASCII 字元,而且開頭一律為前置詞 xn--。Punycode names contain only ASCII characters and always start with the xn-- prefix. 這是為了支援網際網路上現有的 DNS 伺服器,因為大部分的 DNS 伺服器僅支援 ASCII 字元 (請參閱 RFC 3940)。The reason for this is to support existing DNS servers on the Internet, since most DNS servers only support ASCII characters (see RFC 3940).

啟用 IRI 和 IDN 會影響 Uri.DnsSafeHost 屬性的值。Enabling IRI and IDN affects the value of the Uri.DnsSafeHost property. 啟用 IRI 和 IDN 也可以變更 EqualsOriginalStringGetComponentsIsWellFormedOriginalString 方法的行為。Enabling IRI and IDN can also change the behavior of the Equals, OriginalString, GetComponents, and IsWellFormedOriginalString methods.

有三個可能的值進行 IDN 根據所使用的 DNS 伺服器:There are three possible values for IDN depending on the DNS servers that are used:

  • 啟用 idn = Allidn enabled = All

    這個值會將任何 Unicode 網域名稱轉換成 Punycode 的對等名稱 (IDN 名稱)。This value will convert any Unicode domain names to their Punycode equivalents (IDN names).

  • 啟用 idn = AllExceptIntranetidn enabled = AllExceptIntranet

    這個值會轉換不是在本機的內部網路使用 Punycode 的對等名稱 (IDN 名稱) 上的所有 Unicode 網域名稱。This value will convert all Unicode domain names not on the local Intranet to use the Punycode equivalents (IDN names). 在此情況下,若要處理在本機的內部網路上的國際性名稱,用於內部網路的 DNS 伺服器應該支援 Unicode 名稱解析。In this case to handle international names on the local Intranet, the DNS servers that are used for the Intranet should support Unicode name resolution.

  • 啟用 idn = 無idn enabled = None

    這個值不會轉換任何 Unicode 網域名稱即可使用 Punycode。This value will not convert any Unicode domain names to use Punycode. 這是預設值是與.NET Framework 2.0 行為一致。This is the default value which is consistent with the .NET Framework 2.0 behaviour.

當啟用 IRI 剖析 (啟用 Iriparsing> = true) 正規化和字元檢查根據 RFC 3986 和 RFC 3987 中最新的 IRI 規則。When IRI parsing is enabled (iriParsing enabled = true) normalization and character checking are done according to the latest IRI rules in RFC 3986 and RFC 3987. 停用 IRI 剖析時,正規化和字元檢查會根據 RFC 2396 和 RFC 2732 執行 (適用於 IPv6 常值)。When IRI parsing is disabled, normalization and character checking are performed according to RFC 2396 and RFC 2732 (for IPv6 literals). 在.NET Framework 4.5 版之前的版本中,預設值是falseIn versions of the .NET Framework before version 4.5, the default value is false. 在.NET Framework 4.5 版及更新版本中,預設值是true,而且無法修改 IRI 剖析的啟用的狀態中的設定所 .config檔案。In .NET Framework version 4.5 and newer, the default value is true, and the enabled state of IRI parsing cannot be modified by settings in a .config file.

IRI 和 IDN 處理中Uri類別也可以控制使用System.Configuration.IriParsingElementSystem.Configuration.IdnElement,和System.Configuration.UriSection組態設定類別。IRI and IDN processing in the Uri class can also be controlled using the System.Configuration.IriParsingElement, System.Configuration.IdnElement, and System.Configuration.UriSection configuration setting classes. System.Configuration.IriParsingElement 設定可啟用或停用 Uri 類別中的 IRI 處理。The System.Configuration.IriParsingElement setting enables or disables IRI processing in the Uri class. System.Configuration.IdnElement 設定可啟用或停用 Uri 類別中的 IDN 處理。The System.Configuration.IdnElement setting enables or disables IDN processing in the Uri class. System.Configuration.IriParsingElement 設定也可以間接控制 IDN。The System.Configuration.IriParsingElement setting also indirectly controls IDN. 必須啟用 IRI 處理才能進行 IDN 處理。IRI processing must be enabled for IDN processing to be possible. 如果停用 IRI 處理,則 IDN 處理會設定為預設設定,此種情況下,.NET Framework 2.0 行為會用於相容性,但不使用 IDN 名稱。If IRI processing is disabled, then IDN processing will be set to the default setting where the .NET Framework 2.0 behavior is used for compatibility and IDN names are not used.

組態設定System.Configuration.IriParsingElementSystem.Configuration.IdnElement將會讀取一次當第一個System.Uri建構類別。The configuration setting for the System.Configuration.IriParsingElement and System.Configuration.IdnElement will be read once when the first System.Uri class is constructed. 該時間之後的組態設定變更會被忽略。Changes to configuration settings after that time are ignored.

System.GenericUriParser 類別也已經擴充,允許建立可自訂的剖析器,支援 IRI 和 IDN。The System.GenericUriParser class has also been extended to allow creating a customizable parser that supports IRI and IDN. 指定 System.GenericUriParser 物件行為的方法,是將 System.GenericUriParserOptions 列舉中的可用值位元組合傳遞至 System.GenericUriParser 建構函式。The behavior of a System.GenericUriParser object is specified by passing a bitwise combination of the values available in the System.GenericUriParserOptions enumeration to the System.GenericUriParser constructor. GenericUriParserOptions.IriParsing 類型,指出支援 RFC 3987 指定的國際資源識別碼 (IRI) 剖析規則的剖析器。The GenericUriParserOptions.IriParsing type indicates the parser supports the parsing rules specified in RFC 3987 for International Resource Identifiers (IRI). 是否使用 IRI,取決於先前所討論的組態值。Whether IRI is used is dictated by the configuration values previously discussed.

GenericUriParserOptions.Idn 類型,指出剖析器支援主機名稱的國際化網域名稱 (IDN) 剖析。The GenericUriParserOptions.Idn type indicates the parser supports Internationalized Domain Name (IDN) parsing (IDN) of host names. 是否使用 IDN,取決於先前所討論的組態值。Whether IDN is used is dictated by the configuration values previously discussed.

隱含的檔案路徑支援Implicit File Path Support

Uri 也可以用來代表本機檔案系統路徑。Uri can also be used to represent local file system paths. 這些路徑可以表示明確file:// scheme,以開頭的 Uri 中並隱含中並沒有 file:// scheme 的 Uri。These paths can be represented explicitly in URIs that begin with the file:// scheme, and implicitly in URIs that do not have the file:// scheme. 舉一個具體的範例,下列兩個 Uri 都有效,並代表相同的檔案路徑:As a concrete example, the following two URIs are both valid, and represent the same file path:

Uri uri1 = new Uri("C:/test/path/file.txt") // Implicit file path.
Uri uri2 = new Uri("file:///C:/test/path/file.txt") // Explicit file path.

這些隱含的檔案路徑不符合 URI 的規格,且應避免可能的話。These implicit file paths are not compliant with the URI specification and so should be avoided when possible. 當以 Unix 為基礎的系統上使用.NET Core,隱含的檔案路徑可能會特別有問題,因為隱含的絕對檔案路徑難以區分從相對路徑。When using .NET Core on Unix-based systems, implicit file paths can be especially problematic, because an absolute implicit file path is indistinguishable from a relative path. 有,這種模稜兩可時Uri解譯為絕對 URI 路徑的預設值。When such ambiguity is present, Uri default to interpreting the path as an absolute URI.

效能考量Performance Considerations

如果您使用 *Web.config * 檔案,其中包含 Uri 來初始化您的應用程式中,其他時間,才可處理的 Uri,如果配置識別項使用非標準。If you use a *Web.config *file that contains URIs to initialize your application, additional time is required to process the URIs if their scheme identifiers are nonstandard. 在此情況下,受影響的組件,您的應用程式時初始化所需的 Uri,不是在開始時間。In such a case, initialize the affected parts of your application when the URIs are needed, not at start time.

給呼叫者的注意事項

基於安全性考量,您的應用程式時應謹慎小心接受Uri從不受信任來源與執行個體dontEscape設定為true。您可以呼叫來檢查有效的 URI 字串IsWellFormedOriginalString()方法。Because of security concerns, your application should use caution when accepting Uri instances from untrusted sources and with dontEscape set to true.You can check a URI string for validity by calling the IsWellFormedOriginalString() method.

建構函式

Uri(SerializationInfo, StreamingContext) Uri(SerializationInfo, StreamingContext) Uri(SerializationInfo, StreamingContext) Uri(SerializationInfo, StreamingContext)

UriSerializationInfo 類別的已指定執行個體,初始化 StreamingContext 類別的新執行個體。Initializes a new instance of the Uri class from the specified instances of the SerializationInfo and StreamingContext classes.

Uri(String) Uri(String) Uri(String) Uri(String)

使用指定的 URI,初始化 Uri 類別的新執行個體。Initializes a new instance of the Uri class with the specified URI.

Uri(String, Boolean) Uri(String, Boolean) Uri(String, Boolean) Uri(String, Boolean)

以明確的字元逸出控制方式,初始化具有指定 URI 的 Uri 類別的新執行個體。Initializes a new instance of the Uri class with the specified URI, with explicit control of character escaping.

Uri(String, UriKind) Uri(String, UriKind) Uri(String, UriKind) Uri(String, UriKind)

使用指定的 URI,初始化 Uri 類別的新執行個體。Initializes a new instance of the Uri class with the specified URI. 這個建構函式可讓您指定 URI 字串是相對 URI、絕對 URI 或是不定。This constructor allows you to specify if the URI string is a relative URI, absolute URI, or is indeterminate.

Uri(Uri, String) Uri(Uri, String) Uri(Uri, String) Uri(Uri, String)

根據指定的基底 URI 和相對 URI 字串,初始化 Uri 類別的新執行個體。Initializes a new instance of the Uri class based on the specified base URI and relative URI string.

Uri(Uri, String, Boolean) Uri(Uri, String, Boolean) Uri(Uri, String, Boolean) Uri(Uri, String, Boolean)

以明確的字元逸出控制方式,根據指定的基底和相對 URI,初始化 Uri 類別的新執行個體。Initializes a new instance of the Uri class based on the specified base and relative URIs, with explicit control of character escaping.

Uri(Uri, Uri) Uri(Uri, Uri) Uri(Uri, Uri) Uri(Uri, Uri)

根據指定的基底 Uri 執行個體和相對 Uri 執行個體的組合,初始化 Uri 類別的新執行個體。Initializes a new instance of the Uri class based on the combination of a specified base Uri instance and a relative Uri instance.

欄位

SchemeDelimiter SchemeDelimiter SchemeDelimiter SchemeDelimiter

指定會將通訊協定配置和 URI 的位址部分分隔開來的字元。Specifies the characters that separate the communication protocol scheme from the address portion of the URI. 此欄位為唯讀。This field is read-only.

UriSchemeFile UriSchemeFile UriSchemeFile UriSchemeFile

指定 URI 為檔案的指標。Specifies that the URI is a pointer to a file. 此欄位為唯讀。This field is read-only.

UriSchemeFtp UriSchemeFtp UriSchemeFtp UriSchemeFtp

指定 URI 要透過檔案傳輸通訊協定 (File Transfer Protocol,FTP) 存取。Specifies that the URI is accessed through the File Transfer Protocol (FTP). 此欄位為唯讀。This field is read-only.

UriSchemeGopher UriSchemeGopher UriSchemeGopher UriSchemeGopher

指定 URI 要透過 Gopher 通訊協定存取。Specifies that the URI is accessed through the Gopher protocol. 此欄位為唯讀。This field is read-only.

UriSchemeHttp UriSchemeHttp UriSchemeHttp UriSchemeHttp

指定 URI 要透過超文字傳輸協定 (Hypertext Transfer Protocol,HTTP) 存取。Specifies that the URI is accessed through the Hypertext Transfer Protocol (HTTP). 此欄位為唯讀。This field is read-only.

UriSchemeHttps UriSchemeHttps UriSchemeHttps UriSchemeHttps

指定 URI 要透過安全超文字傳輸協定 (Secure Hypertext Transfer Protocol,HTTPS) 存取。Specifies that the URI is accessed through the Secure Hypertext Transfer Protocol (HTTPS). 此欄位為唯讀。This field is read-only.

UriSchemeMailto UriSchemeMailto UriSchemeMailto UriSchemeMailto

指定 URI 為電子郵件地址,並且要透過簡易郵件傳輸通訊協定 (SMTP) 存取。Specifies that the URI is an email address and is accessed through the Simple Mail Transport Protocol (SMTP). 此欄位為唯讀。This field is read-only.

UriSchemeNetPipe UriSchemeNetPipe UriSchemeNetPipe UriSchemeNetPipe

指定 URI 會透過 Windows Communication Foundation (WCF) 所用的 NetPipe 配置來存取。Specifies that the URI is accessed through the NetPipe scheme used by Windows Communication Foundation (WCF). 此欄位為唯讀。This field is read-only.

UriSchemeNetTcp UriSchemeNetTcp UriSchemeNetTcp UriSchemeNetTcp

指定 URI 會透過 Windows Communication Foundation (WCF) 所用的 NetTcp 配置來存取。Specifies that the URI is accessed through the NetTcp scheme used by Windows Communication Foundation (WCF). 此欄位為唯讀。This field is read-only.

UriSchemeNews UriSchemeNews UriSchemeNews UriSchemeNews

指定 URI 為網際網路新聞群組,並且要透過 Network News Transport Protocol (NNTP) 存取。Specifies that the URI is an Internet news group and is accessed through the Network News Transport Protocol (NNTP). 此欄位為唯讀。This field is read-only.

UriSchemeNntp UriSchemeNntp UriSchemeNntp UriSchemeNntp

指定 URI 為網際網路新聞群組,並且要透過 Network News Transport Protocol (NNTP) 存取。Specifies that the URI is an Internet news group and is accessed through the Network News Transport Protocol (NNTP). 此欄位為唯讀。This field is read-only.

屬性

AbsolutePath AbsolutePath AbsolutePath AbsolutePath

取得 URI 的絕對路徑。Gets the absolute path of the URI.

AbsoluteUri AbsoluteUri AbsoluteUri AbsoluteUri

取得絕對 URI。Gets the absolute URI.

Authority Authority Authority Authority

取得伺服器的網域名稱系統 (DNS) 主機名稱或 IP 位址,以及連接埠編號。Gets the Domain Name System (DNS) host name or IP address and the port number for a server.

DnsSafeHost DnsSafeHost DnsSafeHost DnsSafeHost

取得在視需要取消逸出後,可放心用於 DNS 解析的主機名稱。Gets a host name that, after being unescaped if necessary, is safe to use for DNS resolution.

Fragment Fragment Fragment Fragment

取得逸出的 URI 片段。Gets the escaped URI fragment.

Host Host Host Host

取得這個執行個體的主機元件。Gets the host component of this instance.

HostNameType HostNameType HostNameType HostNameType

取得 URI 中所指定主機名稱的類型。Gets the type of the host name specified in the URI.

IdnHost IdnHost IdnHost IdnHost

主機之符合 RFC 3490 標準的國際網域名稱,並適當地使用 Punycode。The RFC 3490 compliant International Domain Name of the host, using Punycode as appropriate. 這個字串在視需要取消逸出後,可放心用於 DNS 解析。This string, after being unescaped if necessary, is safe to use for DNS resolution.

IsAbsoluteUri IsAbsoluteUri IsAbsoluteUri IsAbsoluteUri

取得 Uri 執行個體是否為絕對。Gets whether the Uri instance is absolute.

IsDefaultPort IsDefaultPort IsDefaultPort IsDefaultPort

取得 URI 的通訊埠值是否為這個配置的預設值。Gets whether the port value of the URI is the default for this scheme.

IsFile IsFile IsFile IsFile

取得表示指定的 Uri 是否為檔案 URI 的值。Gets a value indicating whether the specified Uri is a file URI.

IsLoopback IsLoopback IsLoopback IsLoopback

取得指定的 Uri 是否參考本端主機。Gets whether the specified Uri references the local host.

IsUnc IsUnc IsUnc IsUnc

取得指定的 Uri 是否為通用命名慣例 (Universal Naming Convention,UNC) 路徑。Gets whether the specified Uri is a universal naming convention (UNC) path.

LocalPath LocalPath LocalPath LocalPath

取得檔案名稱的本機作業系統表示。Gets a local operating-system representation of a file name.

OriginalString OriginalString OriginalString OriginalString

取得傳遞給 Uri 建構函式的原始 URI 字串。Gets the original URI string that was passed to the Uri constructor.

PathAndQuery PathAndQuery PathAndQuery PathAndQuery

取得以問號 (?) 分隔的 AbsolutePathQuery 屬性。Gets the AbsolutePath and Query properties separated by a question mark (?).

Port Port Port Port

取得這個 URI 的連接埠編號。Gets the port number of this URI.

Query Query Query Query

取得指定的 URI 所包含的任何查詢資訊。Gets any query information included in the specified URI.

Scheme Scheme Scheme Scheme

取得這個 URI 的配置名稱。Gets the scheme name for this URI.

Segments Segments Segments Segments

取得陣列,包含構成指定 URI 的路徑區段。Gets an array containing the path segments that make up the specified URI.

UserEscaped UserEscaped UserEscaped UserEscaped

表示 URI 字串在 Uri 執行個體建立之前即已完全逸出。Indicates that the URI string was completely escaped before the Uri instance was created.

UserInfo UserInfo UserInfo UserInfo

取得與指定 URI 關聯的使用者名稱、密碼或其他使用者特定的資訊。Gets the user name, password, or other user-specific information associated with the specified URI.

方法

Canonicalize() Canonicalize() Canonicalize() Canonicalize()

將內部儲存的 URI 轉換成標準格式。Converts the internally stored URI to canonical form.

CheckHostName(String) CheckHostName(String) CheckHostName(String) CheckHostName(String)

判斷指定的主機名稱是否為有效的 DNS 名稱。Determines whether the specified host name is a valid DNS name.

CheckSchemeName(String) CheckSchemeName(String) CheckSchemeName(String) CheckSchemeName(String)

判斷指定的配置名稱是否有效。Determines whether the specified scheme name is valid.

CheckSecurity() CheckSecurity() CheckSecurity() CheckSecurity()

呼叫這個方法沒有任何作用。Calling this method has no effect.

Compare(Uri, Uri, UriComponents, UriFormat, StringComparison) Compare(Uri, Uri, UriComponents, UriFormat, StringComparison) Compare(Uri, Uri, UriComponents, UriFormat, StringComparison) Compare(Uri, Uri, UriComponents, UriFormat, StringComparison)

使用指定的比較規則,比較兩個 URI 的指定部分。Compares the specified parts of two URIs using the specified comparison rules.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。 Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

比較兩個 Uri 執行個體是否相等。Compares two Uri instances for equality.

Escape() Escape() Escape() Escape()

將路徑元件中的任何不安全或保留字元轉換成十六進位字元表示。Converts any unsafe or reserved characters in the path component to their hexadecimal character representations.

EscapeDataString(String) EscapeDataString(String) EscapeDataString(String) EscapeDataString(String)

將字串轉換成它的逸出表示。Converts a string to its escaped representation.

EscapeString(String) EscapeString(String) EscapeString(String) EscapeString(String)

將字串轉換成它的逸出表示。Converts a string to its escaped representation.

EscapeUriString(String) EscapeUriString(String) EscapeUriString(String) EscapeUriString(String)

將 URI 字串轉換成它的逸出表示。Converts a URI string to its escaped representation.

FromHex(Char) FromHex(Char) FromHex(Char) FromHex(Char)

取得十六進位數字的十進位值。Gets the decimal value of a hexadecimal digit.

GetComponents(UriComponents, UriFormat) GetComponents(UriComponents, UriFormat) GetComponents(UriComponents, UriFormat) GetComponents(UriComponents, UriFormat)

針對特殊字元使用指定的逸出方式,取得目前執行個體的指定元件。Gets the specified components of the current instance using the specified escaping for special characters.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

取得 URI 的雜湊碼。Gets the hash code for the URI.

GetLeftPart(UriPartial) GetLeftPart(UriPartial) GetLeftPart(UriPartial) GetLeftPart(UriPartial)

取得 Uri 執行個體的指定部分。Gets the specified portion of a Uri instance.

GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。 Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

傳回序列化目前執行個體所需的資料。Returns the data needed to serialize the current instance.

GetType() GetType() GetType() GetType()

取得目前執行個體的 Type Gets the Type of the current instance.

(Inherited from Object)
HexEscape(Char) HexEscape(Char) HexEscape(Char) HexEscape(Char)

將指定的字元轉換成其對等的十六進位數字。Converts a specified character into its hexadecimal equivalent.

HexUnescape(String, Int32) HexUnescape(String, Int32) HexUnescape(String, Int32) HexUnescape(String, Int32)

將字元的指定十六進位表示轉換成字元。Converts a specified hexadecimal representation of a character to the character.

InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

取得存留期服務物件,以控制這個執行個體的存留期原則。 Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
IsBadFileSystemCharacter(Char) IsBadFileSystemCharacter(Char) IsBadFileSystemCharacter(Char) IsBadFileSystemCharacter(Char)

取得字元在檔案系統名稱中是否無效。Gets whether a character is invalid in a file system name.

IsBaseOf(Uri) IsBaseOf(Uri) IsBaseOf(Uri) IsBaseOf(Uri)

判斷目前 Uri 執行個體是否為指定之 Uri 執行個體的基底。Determines whether the current Uri instance is a base of the specified Uri instance.

IsExcludedCharacter(Char) IsExcludedCharacter(Char) IsExcludedCharacter(Char) IsExcludedCharacter(Char)

取得是否應該逸出指定的字元。Gets whether the specified character should be escaped.

IsHexDigit(Char) IsHexDigit(Char) IsHexDigit(Char) IsHexDigit(Char)

判斷指定的字元是否為有效的十六進位數字。Determines whether a specified character is a valid hexadecimal digit.

IsHexEncoding(String, Int32) IsHexEncoding(String, Int32) IsHexEncoding(String, Int32) IsHexEncoding(String, Int32)

判斷字串中的字元是否為十六進位編碼。Determines whether a character in a string is hexadecimal encoded.

IsReservedCharacter(Char) IsReservedCharacter(Char) IsReservedCharacter(Char) IsReservedCharacter(Char)

取得指定的字元是否為保留字元。Gets whether the specified character is a reserved character.

IsWellFormedOriginalString() IsWellFormedOriginalString() IsWellFormedOriginalString() IsWellFormedOriginalString()

表示用以建構此 Uri 之字串的語式是否正確,而且不需要進一步逸出。Indicates whether the string used to construct this Uri was well-formed and is not required to be further escaped.

IsWellFormedUriString(String, UriKind) IsWellFormedUriString(String, UriKind) IsWellFormedUriString(String, UriKind) IsWellFormedUriString(String, UriKind)

透過嘗試建構包含此字串的 URI 來表示字串的格式是否正確,且確保該字串不需要進一步逸出。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.

MakeRelative(Uri) MakeRelative(Uri) MakeRelative(Uri) MakeRelative(Uri)

判斷兩個 Uri 執行個體之間的差別。Determines the difference between two Uri instances.

MakeRelativeUri(Uri) MakeRelativeUri(Uri) MakeRelativeUri(Uri) MakeRelativeUri(Uri)

判斷兩個 Uri 執行個體之間的差別。Determines the difference between two Uri instances.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複製。 Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。 Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
Parse() Parse() Parse() Parse()

剖析目前執行個體的 URI,確定它包含有效 URI 所需的所有部分。Parses the URI of the current instance to ensure it contains all the parts required for a valid URI.

ToString() ToString() ToString() ToString()

取得指定之 Uri 執行個體的標準字串表示。Gets a canonical string representation for the specified Uri instance.

TryCreate(String, UriKind, Uri) TryCreate(String, UriKind, Uri) TryCreate(String, UriKind, Uri) TryCreate(String, UriKind, Uri)

使用指定的 Uri 執行個體和 String,建立新的 UriKindCreates a new Uri using the specified String instance and a UriKind.

TryCreate(Uri, String, Uri) TryCreate(Uri, String, Uri) TryCreate(Uri, String, Uri) TryCreate(Uri, String, Uri)

使用指定的基底和相對 Uri 執行個體,建立新的 StringCreates a new Uri using the specified base and relative String instances.

TryCreate(Uri, Uri, Uri) TryCreate(Uri, Uri, Uri) TryCreate(Uri, Uri, Uri) TryCreate(Uri, Uri, Uri)

使用指定的基底和相對 Uri 執行個體,建立新的 UriCreates a new Uri using the specified base and relative Uri instances.

Unescape(String) Unescape(String) Unescape(String) Unescape(String)

轉換指定的字串,方法是將任何逸出序列取代成未逸出的表示。Converts the specified string by replacing any escape sequences with their unescaped representation.

UnescapeDataString(String) UnescapeDataString(String) UnescapeDataString(String) UnescapeDataString(String)

將字串轉換成它的未逸出表示。Converts a string to its unescaped representation.

運算子

Equality(Uri, Uri) Equality(Uri, Uri) Equality(Uri, Uri) Equality(Uri, Uri)

判斷兩個 Uri 執行個體的值是否相同。Determines whether two Uri instances have the same value.

Inequality(Uri, Uri) Inequality(Uri, Uri) Inequality(Uri, Uri) Inequality(Uri, Uri)

判斷兩個 Uri 執行個體的值是否不同。Determines whether two Uri instances do not have the same value.

明確介面實作

ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext)

傳回序列化目前執行個體所需的資料。Returns the data needed to serialize the current instance.

適用於

另請參閱