diff --git a/common/ASC.Core.Common/Context/SecurityContext.cs b/common/ASC.Core.Common/Context/SecurityContext.cs index b0ca20ff205..b602aed346d 100644 --- a/common/ASC.Core.Common/Context/SecurityContext.cs +++ b/common/ASC.Core.Common/Context/SecurityContext.cs @@ -134,6 +134,9 @@ public bool AuthenticateMe(string cookie) if (HttpContextAccessor?.HttpContext != null) { var request = HttpContextAccessor?.HttpContext.Request; + + if (request == null) throw new ArgumentNullException("request"); + ipFrom = "from " + (request.Headers["X-Forwarded-For"].ToString() ?? request.GetUserHostAddress()); address = "for " + request.GetUrlRewriter(); } @@ -189,6 +192,9 @@ public bool AuthenticateMe(string cookie) if (HttpContextAccessor?.HttpContext != null) { var request = HttpContextAccessor?.HttpContext.Request; + + if (request == null) throw new ArgumentNullException("request"); + address = "for " + request.GetUrlRewriter(); ipFrom = "from " + (request.Headers["X-Forwarded-For"].ToString() ?? request.GetUserHostAddress()); }