注销后,浏览器后退按钮重定向到内容页面 [英] Browser back button redirect to content page after logout

查看:158
本文介绍了注销后,浏览器后退按钮重定向到内容页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在进行会话以便在登录/注销时进行跟踪..一旦注销,所有会话都将被清除。

n页面将重定向到登录页面。



但是当我点击退出时,它会清除会话但是在浏览器后退按钮上单击,它将再次重定向到内容页面..



我的代码页代码:



Hi guys,

I'm working on sessions to trace upon login/logout.. once logout all sessions will be cleared.
n the page will redirect to login page.

but when i click logout, its clear the session but on browser back button click, it will again redirecting to the content page..

My Code for ContectPage:

protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["logged_user"] != null || Session["user"] != null || Session["menu"] != null)
            {
                if (!IsPostBack)
                {
                    Repeater1.DataSource = DAL.GenericSP_RS(1, "GetUnitTrackingRS", "");
                    Repeater1.DataBind();
                }

            }
            else
            {
                Session["logged_user"] = null;
                Session["user"] = null;
                Session["menu"] = null;
                Session.Abandon();
                Session.Clear();

                Response.Redirect("Login.aspx");

            }

        }





退出代码页面:





Code for Logout Page:

protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["logged_user"] != null || Session["user"] != null || Session["menu"] != null)
            {
                if (!IsPostBack)
                {
                    Session["logged_user"] = null;
                    Session["user"] = null;
                    Session["menu"] = null;
                    Session.Abandon();
                    Session.Clear();
                    Response.Redirect("Login.aspx");

                }
            }
            else
            {
                Response.Redirect("Login.aspx");
            }
        }







plzzzz帮助我们,我很生气。



谢谢




plzzzz help me guys, i'm sucked.

thanks

推荐答案

推荐



退出后的浏览器后退按钮问题 [ ^ ]


在浏览器中没有缓存











在页面加载中我们将使用以下代码



Response.Cache.SetCacheability(HttpCacheability.NoCache);

Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));

Response.Cache.SetNoStore();



我们需要记住的另一件事是,在主内容页面应用程序中,我们需要检查用户名和密码是否为null在母版页的页面加载中。如果为null,它将始终重定向到登录页面。
For no caching in the browser





In page load we will use the below code

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

One more thing we need to keep in mind that in master content page application, we need to check the username and password for not null in the page load of master page. If null it will always redirect to the login page.


这篇关于注销后,浏览器后退按钮重定向到内容页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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