注销后,如果浏览器后退按钮preSS然后回去最后一个屏幕 [英] After logout if browser back button press then it go back last screen

查看:175
本文介绍了注销后,如果浏览器后退按钮preSS然后回去最后一个屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我在开发第一次在MVC解决方案,所以我面临的一个大问题,
当我从我的应用程序(MVC剃刀Web应用程序)注销它显示登录页面,但如果我preSS浏览器的后退显示上次的屏幕,不想按钮,它我这样做,我想如果我preSS后退按钮它仍显示相同的登录页面。
这里是我的code为注销

 公众的ActionResult退出()
    {
        Session.Clear();
        Session.Abandon();
        Session.RemoveAll();        FormsAuthentication.SignOut();
        this.Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
        this.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        this.Response.Cache.SetNoStore();        返回RedirectToAction(登录);
    }


解决方案

我前一阵子有这个问题,禁用缓存整个应用程序的解决我的问题,只需添加这些行到全局。 asax.cs 文件

 保护无效的Application_BeginRequest()
        {
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
            Response.Cache.SetNoStore();
        }

希望这有助于。

Hello I am developing a solution in MVC in first time so I am facing a big issue, When I logout from my application(mvc razor web application) it displays login page, but if i press browser back button it displays last screen, i don't want this, i want if i press back button it still display same login page. here is my code for logout

public ActionResult Logout()
    {
        Session.Clear();
        Session.Abandon();
        Session.RemoveAll();

        FormsAuthentication.SignOut();


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

        return RedirectToAction("Login");
    }

解决方案

I had this problem a while ago, disabling the cache for the entire application solved my problem, just add these line to the Global.asax.cs file

        protected void Application_BeginRequest()
        {
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
            Response.Cache.SetNoStore();
        }

Hope this helps.

这篇关于注销后,如果浏览器后退按钮preSS然后回去最后一个屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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