当前位置: 代码迷 >> ASP.NET >> 怎么获取ip地址=======
  详细解决方案

怎么获取ip地址=======

热度:7732   发布时间:2013-02-25 00:00:00.0
如何获取ip地址=======
如何获取IP地址,也就是说,当有人点击我们网站的时候把它的IP地址调出来 还有 点击数量 和 是从哪个网站跳到我们网站的

求大神帮帮忙。比较头疼,求思路 最好有代码

------解决方案--------------------------------------------------------
http://blog.csdn.net/yysyangyangyangshan/article/details/6803787
------解决方案--------------------------------------------------------
C# code
/// <summary>        /// 取客户端IP函数        /// </summary>        /// <returns>取客户端IP函数</returns>        public static string GetClientIP()        {            string m_sClientIP = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];            if (m_sClientIP == null || m_sClientIP == String.Empty)            {                m_sClientIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];            }            if (m_sClientIP == null || m_sClientIP == String.Empty)            {                m_sClientIP = HttpContext.Current.Request.UserHostAddress;            }            return m_sClientIP;        }
------解决方案--------------------------------------------------------
string ip = Request.ServerVariables["REMOTE_ADDR"].ToString();
------解决方案--------------------------------------------------------
为什么不用封装好的,还有智能提示的Request.UserHostAddress
  相关解决方案