Getting Local IP Address


public static string GetLocalIP()
{
string _IP = null;

System.Net.IPHostEntry _IPHostEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());

foreach (System.Net.IPAddress _IPAddress in _IPHostEntry.AddressList)
{
if (_IPAddress.AddressFamily.ToString() == "InterNetwork")
{
_IP = _IPAddress.ToString();
}
}
return _IP;
}

 

Sandeep

a dev, an amateur photographer and a father

 

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: