示例#1
0
        public async Task <IActionResult> Logout()
        {
            var deleteCookieOptions = new CookieOptions
            {
                Expires     = DateTimeOffset.UtcNow.AddDays(-100),
                HttpOnly    = true,
                IsEssential = true
            };

            if (Request.Cookies.ContainsKey("key"))
            {
                var key = Request.Cookies["key"];
                memoryCache.Remove($"key={key}");
                Response.Cookies.Append("key", "", deleteCookieOptions);
                await authRepo.DeleteAuthEntry(key);
            }
            if (Request.Cookies.ContainsKey("state"))
            {
                Response.Cookies.Append("state", "", deleteCookieOptions);
            }
            return(RedirectToAction("Index", "Home"));
        }