0

我使用此代码进行注销

public ActionResult LogOff()
    {

         FormsAuthentication.SignOut();

        // Drop all the information held in the session
        Session.Clear();
        Session.Abandon();

        // clear authentication cookie
        HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, "");
        cookie1.Expires = DateTime.Now.AddYears(-1);
        Response.Cookies.Add(cookie1);

        // clear session cookie
        HttpCookie cookie2 = new HttpCookie("ASP.NET_SessionId", "");
        cookie2.Expires = DateTime.Now.AddYears(-1);
        Response.Cookies.Add(cookie2);
        foreach (var cookie in Request.Cookies.AllKeys)
        {
            Request.Cookies.Remove(cookie);
        }

        return RedirectToAction("Index", "Home");

    }

并且它在本地工作正常,但是当我在服务器中发布我的应用程序时,即使用户已经注销,如果用户单击浏览器的Back按钮,页面仍然会显示。

4

1 回答 1

0

我希望您只是看到页面的缓存版本。

如果您按 CTRL+F5 是否会要求您再次登录?

如果您真的想禁用此功能,请参阅MiBu 给出的此答案,以防止缓存安全页面。

于 2013-02-07T02:42:26.493 回答