获取客户端IP

   string clientIP = HttpContext.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                    if (string.IsNullOrEmpty(clientIP))
                        clientIP = HttpContext.Request.ServerVariables["REMOTE_ADDR"];
                    if (string.IsNullOrEmpty(clientIP))
                        clientIP = HttpContext.Request.UserHostAddress;

posted on 2012-10-08 11:37  静欲动  阅读(92)  评论(0编辑  收藏  举报

导航