Uri.IdnHost Uri.IdnHost Uri.IdnHost Uri.IdnHost Property

定义

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.

public:
 property System::String ^ IdnHost { System::String ^ get(); };
public string IdnHost { get; }
member this.IdnHost : string
Public ReadOnly Property IdnHost As String

属性值

根据 IDN 标准, 用 Punycode 格式化的主机名。The hostname, formatted with Punycode according to the IDN standard.

异常

此实例代表一个相对 URI,而此属性仅对绝对 URI 有效。This instance represents a relative URI, and this property is valid only for absolute URIs.

注解

提供此属性是为了使用需要以 Punycode 形式使用域名的更低级别网络协议。This property is provided for the use of lower-level networking protocols that require the domain name in Punycode form. 如果你的代码不需要该特定格式, 则Host将用于主机名。If your code does not require that specific format, use Host for the hostname.

不推荐DnsSafeHost使用的属性依赖于app.config设置, Windows 应用商店应用程序无法更改这些设置。The deprecated DnsSafeHost property is dependent on app.config settings, which cannot be changed by Windows Store applications. IdnHost 作为首选替代方法DnsSafeHost提供, 因为IdnHost无论当前的app.config设置如何, 都可以保证 DNS 安全。IdnHost is provided as the preferred alternative to using DnsSafeHost, because IdnHost is guaranteed to always be DNS safe, no matter what the current app.config settings might be.

如果使用了转义字符串构造此实例 (例如"http://[fe80::200:39ff:fe36:1a2d%254]/temp/example.htm"), 则 IdnHost 将返回一个转义字符串。If you used an escaped string to construct this instance (for example, "http://[fe80::200:39ff:fe36:1a2d%254]/temp/example.htm"), then IdnHost returns an escaped string. 应在使用该字符串进行 DNS 解析之前, unescape 从 IdnHost 返回的任何转义字符串。You should unescape any escaped string returned from IdnHost before using that string for DNS resolution. 请注意, 如果使用无效的非转义字符串来构造此实例 (例如, "http://[fe80:: 200: 39ff: fe36: 1a2d% 4]/temp/example.htm"), 则 IdnHost 将返回未转义的字符串。Be aware that if you used an invalid unescaped string to construct this instance (for example, "http://[fe80::200:39ff:fe36:1a2d%4]/temp/example.htm"), then IdnHost returns an unescaped string.

适用于