Convert Domain Name to IP Address

Feb 9, 2010 Posted by Lara Kannan
How to convert Domain Name to IP Address in C#?

The answer is quiet simple. Just use the System.Net.Dns class

using System.Net;

protected void Page_Load(object sender, EventArgs e)
{
foreach (IPAddress address in Dns.GetHostAddresses("www.youraddress.com"))
{
Response.Write(address.ToString());
}
}


Share
Labels: ,

Post a Comment