adjust ip address extensions again

This commit is contained in:
rootdarkarchon
2023-02-10 15:15:33 +01:00
parent 42694a872f
commit 03d7549d29

View File

@@ -16,11 +16,14 @@ public static class Extensions
var ipAddress = accessor.HttpContext.GetServerVariable("HTTP_X_FORWARDED_FOR");
if (!string.IsNullOrEmpty(ipAddress))
if (!string.IsNullOrWhiteSpace(ipAddress))
{
var addresses = ipAddress.Split(',', StringSplitOptions.RemoveEmptyEntries);
if (addresses.Length != 0)
return addresses.Last();
var lastEntry = addresses.LastOrDefault();
if (lastEntry != null)
{
return lastEntry;
}
}
return accessor.HttpContext.Connection.RemoteIpAddress.ToString();