Getting Host name in C#

Tamilmaran
Posted by Tamilmaran under C# category on | Views : 2421
Hi!


Below is the simple code to get the host name



try
{
string webURL = textBox1.Text ;
IPAddress[] URLaddresslist = Dns.GetHostAddresses(webURL);

foreach (IPAddress URLaddress in URLaddresslist)
{
MessageBox.Show(URLaddress.ToString());
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message );
}

Comments or Responses

Login to post response