Get IP address of client machine

前端 未结 4 1290
情书的邮戳
情书的邮戳 2020-12-09 11:09

I am trying to get the IP address of client machine using C#. I am using the below code to get the IP address :

string IPAddress = HttpContext.Current.Reque         


        
4条回答
  •  渐次进展
    2020-12-09 11:31

    In my project it's required to get the local PC IP. So i use it Please try the below code

    string strHostName = System.Net.Dns.GetHostName();
    IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(strHostName);
    IPAddress[] addr = ipEntry.AddressList;
    string ip = addr[1].ToString();
    

提交回复
热议问题