gpt4 book ai didi

asp.net-mvc - ASP.NET MVC : Logging out in the view once called

转载 作者:行者123 更新时间:2023-12-02 00:36:31 24 4
gpt4 key购买 nike

我有一个指向注销 View 的注销操作。点击注销按钮后仍然显示用户信息。我转到不同的 url 后完全注销,这是为什么?我该如何处理?客户端重定向?

行动:

    public ViewResult LogOut()
{
FormsAuthentication.SignOut();
return View();
}

最佳答案

尝试去掉身份验证 token :

FormsAuthentication.SignOut();
Context.Response.Cookies.Item(FormsAuthentication.FormsCookieName).Expires = Date.Now;
return RedirectToAction("LogOut");

此外,确保页面未被缓存:

Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetNoStore();

关于asp.net-mvc - ASP.NET MVC : Logging out in the view once called,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4404819/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com