发布:2023/12/7 15:17:32作者:大数据 来源:大数据 浏览次数:426
string ip = Request.Headers["X-Forwarded-For"].FirstOrDefault();
if (string.IsNullOrEmpty(ip))
ip = Request.HttpContext.Connection.RemoteIpAddress.ToString();
获取用户IP或IP访问地址,上面的可简化成
string ip=Request.Headers["X-Forwarded-For"].FirstOrDefault() ?? Request.HttpContext.Connection.RemoteIpAddress.ToString();
© Copyright 2014 - 2024 柏港建站平台 ejk5.com. 渝ICP备16000791号-4