How to get the IP address of the server on which my C# application is running on?

前端 未结 26 2502
天命终不由人
天命终不由人 2020-11-22 06:01

I am running a server, and I want to display my own IP address.

What is the syntax for getting the computer\'s own (if possible, external) IP address?

Someon

26条回答
  •  情书的邮戳
    2020-11-22 06:47

    I just thought that I would add my own, one-liner (even though there are many other useful answers already).


    string ipAddress = new WebClient().DownloadString("http://icanhazip.com");

提交回复
热议问题