有时候用别的方法获取的ip都是192.168.0.1这类的ip,不是真实的ip,请问一下大家,用js怎么获取真实的ip和地点,谢谢!

解决方案 »

  1.   

    1、String user_IP=Request.ServerVariables["REMOTE_ADDR"].ToString(); 
    取远程用户IP地址 2、穿过代理服务器取远程用户真实IP地址: 
    if(Request.ServerVariables["HTTP_VIA"]!=null){ 
    string user_IP=Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString(); 
    }else{ 
    string user_IP=Request.ServerVariables["REMOTE_ADDR"].ToString(); 
      

  2.   

    1、String user_IP=Request.ServerVariables["REMOTE_ADDR"].ToString(); 
    取远程用户IP地址 2、穿过代理服务器取远程用户真实IP地址: 
    if(Request.ServerVariables["HTTP_VIA"]!=null){ 
    string user_IP=Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString(); 
    }else{ 
    string user_IP=Request.ServerVariables["REMOTE_ADDR"].ToString(); 
      

  3.   

    这个问题我曾经也弄了很久...现在用的是这个
    //IP地址
            string ip = "" ;
            System.Web.HttpContext context = System.Web.HttpContext.Current;
            if (context.Request.ServerVariables["HTTP_VIA"] != null)//判断是否有代理
            {
                ip = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
            }
            else
            {
                ip = context.Request.ServerVariables["REMOTE_ADDR"].ToString();
            }
      

  4.   

    通过httpwebrequest到ip138获取IP和地区名称或
    http://topic.csdn.net/u/20090617/11/8f0432b6-84ee-49da-a55f-86b3d343ab8b.html