注销后,asp.net mvc中的浏览器缓存问题 [英] browser cache problem in asp.net mvc after logout

查看:132
本文介绍了注销后,asp.net mvc中的浏览器缓存问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我按下浏览器的后退"按钮时,它显示了上次访问的页面.这是注销后的代码.

Hi,

when i hit the browser back button ,it shows the last accessed page. This is the code after log out.

public ActionResult LogOff()
       {
           FormsAuthentication.SignOut();
           Session.Abandon();

           // Invalidate the Cache on the Client Side

           foreach (var cookie in Request.Cookies.AllKeys)
           {
               Request.Cookies.Remove(cookie);
           }
           foreach (var cookie in Response.Cookies.AllKeys)
           {
               Response.Cookies.Remove(cookie);
           }


           return RedirectToAction("LogOn", "Account");
       }





感谢您的帮助.





Thanks for helping.

推荐答案

根据您在浏览器中的缓存设置,缓存在浏览器中访问的页面.您需要防止在ASP.net MVC中进行缓存,以便浏览器不会缓存它们.执行完此操作后,请尝试清除浏览器的缓存,然后再次尝试加载页面.注销并尝试返回按钮.您应该收到一条消息,指出该页面不再存在.

有很多方法可以防止ASP.net页被缓存在浏览器中.一种方法是在呈现页面之前执行此操作.

The pages you visit in your browser are cached depending upon your caching settings in the browser. You need to prevent caching in ASP.net MVC so that they are not cached by the browser. After you do that try clearing your browsers cache and try loading the page again. Logout and try the back button. You should get a message saying that the page no longer exists or something.

There are many ways of preventing your ASP.net pages from getting cached in the browser. One such way is to do this before the page is rendered.

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


这篇关于注销后,asp.net mvc中的浏览器缓存问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆