What's my IP from C#

C#

Please contribute by voting. Thanks!
1

Do you need to get public/external IP address from your C# program? Here's a little snippet that helps you:

string externalip = new WebClient().DownloadString("http://icanhazip.com");            
Console.WriteLine(externalip); //Writes your IP address and nothing more

If you do a GET-request the site only returns your public IP-address as text/plain. Other methods are available in this SO-thread

Article created: May 31 at 07:43. Edited May 31 at 07:44.

Your comment

You need to sign up / log in to comment this article

Author

Created by Mika [4] May 31 at 07:43

Share article

Do you know about

TFS?

Write an article