0
그래서 HttpContext
을 사용하여 클라이언트 IP를 가져 오는 정적 방법이 있습니다.로깅 중 클라이언트 IP 가져 오기
public static string GetClientMachineIPAddress()
{
string strClientIP = string.Empty;
if (HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null ||!string.IsNullOrEmpty(HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]))
{
strClientIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
if (strClientIP == string.Empty)
{
strClientIP = HttpContext.Current.Request.UserHostAddress;
}
return strClientIP;
}
이 사용자가 이미 로그인 할 때 잘 작동하지만 난 세션이 설정되기 전에 null의 HttpContext.Current
이후 로그인시 IP를 얻을하려고하면 작동하지 않습니다.
어떤 아이디어라도 만족합니다!