1、HttpContext.Current.Request.UserHostAddress;

2、HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

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

 

4、HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

5、private string GetClientIP()
  {
   string result HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
   if (null == result || result == String.Empty)
   {
    result HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
   }

   if (null == result || result == String.Empty)
   {
    result HttpContext.Current.Request.UserHostAddress;
   }
   return result;
  }

posted on 2009-07-09 14:03  梅桦  阅读(305)  评论(0编辑  收藏  举报