.aspx 获取本机的局域网ip
服务器局域网ip:192.168.145.1
本机局域网ip: 192.168.145.2
网站http://192.168.145.1/test/ 发布到192.168.145.1
在192.168.145.2访问http://192.168.145.1/test时想得到本机ip: 192.168.145.2
方法: string strHostName = System.Net.Dns.GetHostName();
string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
return clientIPAddress.ToString();
只能返回:192.168.145.1
各位大神何解?
------解决方案--------------------
HttpContext.Current.Request.UserHostAddress;