string strHostName = System.Net.Dns.GetHostName(); //clientIPAddress是一个数组,可能有多个数据 var clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName); string clientip = clientIPAddress.GetValue(0).ToString();
示例代码
Find Client IP Address And Location in ASP.NET