Uri.CheckHostName(String) Uri.CheckHostName(String) Uri.CheckHostName(String) Uri.CheckHostName(String) Method

定义

确定指定的主机名是否为有效的 DNS 名称。Determines whether the specified host name is a valid DNS name.

public:
 static UriHostNameType CheckHostName(System::String ^ name);
public static UriHostNameType CheckHostName (string name);
static member CheckHostName : string -> UriHostNameType
Public Shared Function CheckHostName (name As String) As UriHostNameType

参数

name
String String String String

要验证的主机名。The host name to validate. 可以是 IPv4 或 IPv6 地址或 Internet 主机名。This can be an IPv4 or IPv6 address or an Internet host name.

返回

指示主机名类型的 UriHostNameTypeA UriHostNameType that indicates the type of the host name. 如果无法确定主机名的类型,或者主机名为 null 或零长度字符串,则此方法返回 UnknownIf the type of the host name cannot be determined or if the host name is null or a zero-length string, this method returns Unknown.

示例

下面的示例将检查主机名是否有效。The following example checks whether the host name is valid.

Console::WriteLine( Uri::CheckHostName( "www.contoso.com" ) );
Console.WriteLine(Uri.CheckHostName("www.contoso.com"));
   
Console.WriteLine(Uri.CheckHostName("www.contoso.com"))

注解

CheckHostName方法检查提供的主机名是否满足有效 Internet 主机名的要求。The CheckHostName method checks that the host name provided meets the requirements for a valid Internet host name. 但是,它不会执行主机名查找来验证主机是否存在。It does not, however, perform a host-name lookup to verify the existence of the host.

适用于