diff --git a/zero.Core/Extensions/HttpContextExtensions.cs b/zero.Core/Extensions/HttpContextExtensions.cs index 107b0094..2edc77de 100644 --- a/zero.Core/Extensions/HttpContextExtensions.cs +++ b/zero.Core/Extensions/HttpContextExtensions.cs @@ -40,5 +40,16 @@ namespace zero.Core.Extensions return context.Request.Headers["Accept"] == "application/json"; } + + + /// + /// Get IP Address of the client + /// + public static string GetClientIpAddress(this HttpContext context) + { + return context.Connection.RemoteIpAddress?.ToString(); + //string ipAddress = context.GetServerVariable("HTTP_X_FORWARDED_FOR"); + //return !ipAddress.IsNullOrEmpty() ? ipAddress.Split(',')[0] : context.GetServerVariable("REMOTE_ADDR"); + } } }