HostString 結構

定義

表示 URI 的主機部分可用來建構正確格式化和編碼的 URI,以用於 HTTP 標頭。

public value class HostString : IEquatable<Microsoft::AspNetCore::Http::HostString>
public struct HostString : IEquatable<Microsoft.AspNetCore.Http.HostString>
public readonly struct HostString : IEquatable<Microsoft.AspNetCore.Http.HostString>
type HostString = struct
Public Structure HostString
Implements IEquatable(Of HostString)
繼承
HostString
實作

建構函式

HostString(String)

不經修改而建立新的 HostString。 值應該為 Unicode 而不是 Punycode,且可以有連接埠。 也允許 IPv4 和 IPv6 位址,一樣可以有連接埠。

HostString(String, Int32)

從其主機和埠元件建立新的 HostString。

屬性

HasValue

如果已設定主機,則會傳回 true。

Host

傳回 值之主機部分的值。 如果埠存在,則會移除埠。 IPv6 位址會加上方括弧 (如果沒有的話)。

Port

傳回主機埠部分的值,如果找不到任何埠部分,則傳回 null 。

Value

從建構函式傳回原始值。

方法

Equals(HostString)

比較 Value 屬性是否相同,忽略大小寫。

Equals(Object)

只有當給定的物件為 HostString 時,才會與之做比較。

FromUriComponent(String)

從指定的 URI 元件建立新的 HostString。 任何 Punycode 會轉換成 Unicode。

FromUriComponent(Uri)

從給定 URI 執行個體的主機和連接埠建立新的 HostString。 Punycode 會轉換成 Unicode。

GetHashCode()

取得值的雜湊碼。

MatchesAny(StringSegment, IList<StringSegment>)

比對主機標頭值的主機部分與模式清單。 只要模式使用相同的格式,主機可能是編碼的 punycode 或解碼 Unicode 格式。

ToString()

傳回以 ToUriComponent() 標準化的值。

ToUriComponent()

傳回經過適當格化和編碼的值,以用於 HTTP 標頭中的 URI。 任何 Unicode 會轉換成 Punycode。 IPv6 位址會加上方括弧 (如果沒有的話)。

運算子

Equality(HostString, HostString)

比較兩個執行個體是否相同。

Inequality(HostString, HostString)

比較兩個執行個體是否不相同。

適用於