public static bool TryGetAccountId(HttpRequest request, out int accountId) { accountId = 0; StringValues accountTokenValues; if (request.Headers.TryGetValue("Account-Token", out accountTokenValues)) { string token = accountTokenValues.FirstOrDefault(); if (!string.IsNullOrWhiteSpace(token)) { accountId = AccountHandler.GetIdByToken(Guid.Parse(token)); if (accountId > 0) { return(true); } } } return(false); }