asp.net获取网页客户端IP地址

第一种:Request.UserHostAddress;   //获取IP

第二种:HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

第三种是获取部署地址的IP:

string strHostName = System.Net.Dns.GetHostName();
string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();

posted on 2015-01-05 17:12  荧明  阅读(300)  评论(0编辑  收藏  举报

导航