Get IP address from Domain name server by hostname in C#

This code is in c# to retrieve IP address corresponding to any hostname from Domain name server


string hostname = "www.dotnetspider.com";
IPAddress[] addresslist = Dns.GetHostAddresses(hostname);

foreach (IPAddress theaddress in addresslist)
{
Response.Write(theaddress.ToString());
Response.Write("NewLine");
}


in the second response we have a line brake. age is not visible so i am placing "NewLine" there.

don't forget to use

using System.Net;


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: