Convert Domain Name to IP Address

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());
}
}

Leave a Reply