Muokkaa

Jaa


Uri.CheckHostName(String) Method

Definition

Determines whether the specified host name is a valid DNS name.

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

Parameters

name
String

The host name to validate. This can be an IPv4 or IPv6 address or an Internet host name.

Returns

The type of the host name. If 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.

Examples

The following example checks whether the host name is valid.

Console::WriteLine( Uri::CheckHostName( "www.contoso.com" ) );
Console.WriteLine(Uri.CheckHostName("www.contoso.com"));
printfn $"""{Uri.CheckHostName "www.contoso.com"}"""
Console.WriteLine(Uri.CheckHostName("www.contoso.com"))

Remarks

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.

Applies to