ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 1、得到客户端真实IP ``` /// <summary> /// 提取开启代理/cdn服务后的客户端真实IP /// </summary> /// <returns></returns> public static string GetTrueIP() { string ip = string.Empty; string X_Forwarded_For = HttpContext.Current.Request.Headers["X-Forwarded-For"]; if (!string.IsNullOrWhiteSpace(X_Forwarded_For)) { ip = X_Forwarded_For; } else { string CF_Connecting_IP = HttpContext.Current.Request.Headers["CF-Connecting-IP"]; if (!string.IsNullOrWhiteSpace(CF_Connecting_IP)) { ip = CF_Connecting_IP; } else { ip = HttpContext.Current.Request.UserHostAddress; } } return ip; } } ``` # 使用 ``` string ip=GetTrueIP(); ```