Answers for "Request.ServerVariables["HTTP_X_FORWARDED_FOR"] get only one ipaddress"

C#
1

Request.ServerVariables["HTTP_X_FORWARDED_FOR"] get only one ipaddress

private string GetUserIP()
{
  string ipList = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

  if (!string.IsNullOrEmpty(ipList))
  {
    return ipList.Split(',')[0];
  }

  return Request.ServerVariables["REMOTE_ADDR"];
}
Posted by: Guest on June-10-2020

Code answers related to "Request.ServerVariables["HTTP_X_FORWARDED_FOR"] get only one ipaddress"

C# Answers by Framework

Browse Popular Code Answers by Language