Resolving hostname to its IP addresses

Resolving hostname to its IP addresses

using System.Net;

public partial class HostNametoIp : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Define the hostname to resolve
string host = “www.microsoft.com”;

// A host can have multiple IP addresses
IPAddress[] addresses = Dns.GetHostAddresses(host);
foreach (IPAddress addr in addresses)
{
Response.Write(addr.ToString());
}
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s