0

How can I get the wan IP address for my machine programmatically using C# vs2008.

zondo
  • 19,901
  • 8
  • 44
  • 83
KHALID
  • 143
  • 5
  • 16

2 Answers2

1

I found the solution (the function gets my external IP address)

This is the function:

public string getdata()
{
    UTF8Encoding utf8 = new UTF8Encoding();
    WebClient webClient = new WebClient();
    String externalIp = utf8.GetString(webClient.DownloadData("http://whatismyip.com/automation/n09230945.asp"));           
    return externalIp;
}
zondo
  • 19,901
  • 8
  • 44
  • 83
KHALID
  • 143
  • 5
  • 16
1
public string getdata()
{ 
    UTF8Encoding utf8 = new UTF8Encoding();
    WebClient webClient = new WebClient();
    String externalIp = utf8.GetString(webClient.DownloadData("http://automation.whatismyip.com/n09230945.asp"));
    return externalIp;
}
J. Mitchell
  • 340
  • 4
  • 14
KHALID
  • 143
  • 5
  • 16