How to Get IP Address using Host Name

Waqas Anwar
01 December 2010
10284 Views

You want to get the IP Address of a given host name, you can use System.Net.Dns.GetHostAddresses method that returns System.Net.IPAddress array.

System.Net.IPAddress[] IPAddresses =
   System.Net.Dns.GetHostAddresses("mail.yahoo.com");


ListBox1.DataSource = IPAddresses;
ListBox1.DataBind();