Uri.CheckHostName(String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應