I have a computer on the local network, behind a NAT router. I have some 192.168.0.x addresses, but I really want to know my public IP address, not somethin
If you are worried about connection lose or the availability of the site, you can also try this way to avoid that issue by including above suggestions.
using System.Threading;
Task[] tasks = new[]
{
Task.Factory.StartNew( () => new System.Net.WebClient().DownloadString(@"http://icanhazip.com").Trim() ),
Task.Factory.StartNew( () => new System.Net.WebClient().DownloadString(@"http://checkip.dyndns.org").Trim() )
};
int index = Task.WaitAny( tasks );
string ip = tasks[index].Result;
Hope this one also help.