抓取Client端的IP Address

  • 5985
  • 0

摘要:抓取Client端的IP Address


//方法一(127.0.0.1)
HttpContext.Current.Request.UserHostAddress; 

//方法二(127.0.0.1)
HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

//方法三(抓出來的IP位址如同在CMD下打ipconfig)
string strHostName = System.Net.Dns.GetHostName();
string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();

//方法四(無視代理)
HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

 






Y2J's Life:http://kimenyeh.blogspot.tw/