📌  相关文章
📜  Request.ServerVariables["HTTP_X_FORWARDED_FOR"] 只获取一个 ipaddress - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:03.990000             🧑  作者: Mango

代码示例1
private string GetUserIP()
{
  string ipList = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

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

  return Request.ServerVariables["REMOTE_ADDR"];
}