string strHostName = System.Net.Dns.GetHostName();
//clientIPAddress是一个数组,可能有多个数据
var clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName);
string clientip = clientIPAddress.GetValue(0).ToString();
转载于:https://www.cnblogs.com/Lulus/p/9741745.html