01.Blogs :
CCTING  

External IP + C# + Router IP Rated Average [3 out of 5].

There are many ways of detecting external IP of router. One of the easiest if using "web services".
However, this method has risk of using because the web service may change anytime and therefore this method will no more applicable.
I will talk about how to request external IP from "external DNS" in other time. Today i talk about the easiest way first.
System.Net.HttpWebRequest request =
(System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("http://www.what
ismyip.org/");

request.UserAgent = "User-Agent: Mozilla/4.0 (compatible; MSIE
6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
System.Net.HttpWebResponse response =
	(System.Net.HttpWebResponse)request.GetResponse();

string myExternalIP = string.Empty;

using (System.IO.StreamReader reader = new
	StreamReader(response.GetResponseStream()))
{

	myExternalIP = reader.ReadToEnd();
	reader.Close();
}

response.Close();
MessageBox.Show(myExternalIP);

posted on Friday, December 01, 2006 9:16 AM by CCTING


 
03.UPDATE CALENDAR :
<December 2006>
SunMonTueWedThuFriSat
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

05.MY LINKS :

07.Subscriptions :

Subscriptions


© Copyright 2005 Microsoft Corporation. All Rights Reserved.
Terms of Use | Privacy Statement | Code of Conduct | Hosted by MaximumASP for Microsoft
WHO-BAR