Dns Class

Provides simple domain name resolution functionality.

Namespace:  System.Net
Assembly:  System (in System.dll)

public static class Dns

The Dns type exposes the following members.

  NameDescription
Public methodStatic memberBeginGetHostAddressesAsynchronously returns the Internet Protocol (IP) addresses for the specified host.
Public methodStatic memberBeginGetHostByName Obsolete. Begins an asynchronous request for IPHostEntry information about the specified DNS host name.
Public methodStatic memberBeginGetHostEntry(IPAddress, AsyncCallback, Object)Asynchronously resolves an IP address to an IPHostEntry instance.
Public methodStatic memberBeginGetHostEntry(String, AsyncCallback, Object)Asynchronously resolves a host name or IP address to an IPHostEntry instance.
Public methodStatic memberBeginResolve Obsolete. Begins an asynchronous request to resolve a DNS host name or IP address to an IPAddress instance.
Public methodStatic memberEndGetHostAddressesEnds an asynchronous request for DNS information.
Public methodStatic memberEndGetHostByName Obsolete. Ends an asynchronous request for DNS information.
Public methodStatic memberEndGetHostEntryEnds an asynchronous request for DNS information.
Public methodStatic memberEndResolve Obsolete. Ends an asynchronous request for DNS information.
Public methodStatic memberGetHostAddressesReturns the Internet Protocol (IP) addresses for the specified host.
Public methodStatic memberGetHostAddressesAsyncReturns the Internet Protocol (IP) addresses for the specified host as an asynchronous operation.
Public methodStatic memberGetHostByAddress(IPAddress) Obsolete. Creates an IPHostEntry instance from the specified IPAddress.
Public methodStatic memberGetHostByAddress(String) Obsolete. Creates an IPHostEntry instance from an IP address.
Public methodStatic memberGetHostByName Obsolete. Gets the DNS information for the specified DNS host name.
Public methodStatic memberGetHostEntry(IPAddress)Resolves an IP address to an IPHostEntry instance.
Public methodStatic memberGetHostEntry(String)Resolves a host name or IP address to an IPHostEntry instance.
Public methodStatic memberGetHostEntryAsync(IPAddress)Resolves an IP address to an IPHostEntry instance as an asynchronous operation.
Public methodStatic memberGetHostEntryAsync(String)Resolves a host name or IP address to an IPHostEntry instance as an asynchronous operation.
Public methodStatic memberGetHostNameGets the host name of the local computer.
Public methodStatic memberResolve Obsolete. Resolves a DNS host name or IP address to an IPHostEntry instance.
Top

The Dns class is a static class that retrieves information about a specific host from the Internet Domain Name System (DNS).

The host information from the DNS query is returned in an instance of the IPHostEntry class. If the specified host has more than one entry in the DNS database, IPHostEntry contains multiple IP addresses and aliases.

The following example queries the DNS database for information on the host www.contoso.com.

IPHostEntry hostInfo = Dns.GetHostByName("www.contoso.com");
   

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft