Monday 5 March 2012

How to get IP address by Hostname from Domain name Server in C#

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

string hostname = http://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;

No comments:

Post a Comment