public void OnGet()
{
Result = GetClientIP(this.HttpContext);
}
public static string GetClientIP(HttpContext httpContext)
{
string ip;
if (!string.IsNullOrEmpty(httpContext.Request.Headers["X-Azure-SocketIP"]))
{
ip = httpContext.Request.Headers["X-Azure-SocketIP"].ToString().Split(',').FirstOrDefault();
ip = System.Net.IPAddress.Parse(ip).MapToIPv4().ToString();
}
else
{
ip = httpContext.Connection.RemoteIpAddress.MapToIPv4().ToString();
}
return ip;
}
來源也不可考了謝謝開源的各位大大
--
The bug existed in all possible states.
Until I ran the code.