Request.UserHostAddress  简单的

解决方案 »

  1.   

    string userIp=Request.UserHostAddress ;
      

  2.   

    HttpRequest.UserHostAddress
    Gets the IP host address of the remote client.
      

  3.   

    这个就是request对象的一个属性,request.UserHostAddress 
      

  4.   

    /// <summary>
    /// 获得客户端真实ip,穿透代理服务器
    /// </summary>
    public static System.String getClientIP(System.Web.HttpRequest request)
    {
    System.String ClientIP = killStringNull(request.ServerVariables.Get("HTTP_X_FORWARDED_FOR"));
    if(ClientIP.Equals(""))
    {
    ClientIP = request.ServerVariables.Get("Remote_Addr").ToString();
    }
    return ClientIP;
    }
      

  5.   

    漏掉一个。killStringNull是我自已定义的一个方法。
    public static String killStringNull(Object stringValue)
    {
    try
    {
    return stringValue.ToString().Trim();
    }
    catch { }
    return "";
    }
      

  6.   

    请问下  这是 做网页  还是 win form   或是其他
    如果 是编winform  应该怎么写
      

  7.   

    有没有人知道winform的怎么写?不要光写网页的