Friday, December 28, 2012

How to get website IP address in ASP.NET

Using the below code you can get the IP address of a website just by passing the URL of the website.

private void GetIPAddress()
   //Pass website URL
   string URL = "";
  //Remove http://
   string tempUrl = URL.Replace("http://", "").Replace("https://", "").Trim();
  //Split sub domains and get the domain name
   string[] arrURL = tempUrl.Split('/');
   string SiteURL = arrURL[0];
   System.Net.IPAddress[] ip = System.Net.Dns.GetHostAddresses(SiteURL);


No comments:
Write comments
Recommended Posts × +