IP address of the user who is browsing my website

后端 未结 4 1312
梦毁少年i
梦毁少年i 2021-01-07 07:59

I want to know the IP address of the client machine, i.e. the IP address of the user who is browsing my website. I am trying the following code but it is returning server ad

4条回答
  •  Happy的楠姐
    2021-01-07 08:34

    string IPAddress = string.Empty;
    string SearchName = string.Empty;
    
    String strHostName = HttpContext.Current.Request.UserHostAddress.ToString();
    
    IPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
    

提交回复
热议问题