在asp.net中注销浏览器的问题的后退按钮 [英] back button of browser issue in asp.net logout

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

问题描述

当我注销按钮点击,一切都会好后点击后面的浏览器用户的按钮不进入或登录..thats也不错(不过,任何情况下,点击主页;工作是好的)。

和,任何情况下点击喜欢的搜索项目(我的意思是通过点击按钮使用选择查询或取数据)

注销按钮的工作并不好......其工作像正常的页面;即。 &安培;当我在注销点击...使用 Session.clear()重定向到主页; Redirect.Response(page.aspx)

使用此code,后面的母版页的Page_Load:

 如果(!的IsPostBack)
        {            如果(会话[名称] == NULL)
            {                的Response.Redirect(Default.aspx的);
            }            其他
            {                Response.ClearHeaders();                Response.AddHeader(缓存控制,无缓存,无存储,最大年龄= 0,必重新验证);                Response.AddHeader(杂注,无缓存);                Label1.Text =欢迎++会话[名称];
            }

现在我想禁用后退按钮不使用JavaScript,因为理由是当有人阻止浏览器的JavaScript ....同样的问题发生。


解决方案

 私人无效的Page_Load(对象发件人,EventArgs的发送)
    {
        //把用户code到这里初始化页面
        如果(会话[的SessionID] == NULL)
        {
            的Response.Redirect(的Login.aspx);
        }
        将Response.Buffer =真;
        Response.ExpiresAbsolute = DateTime.Now.AddDays(-1d);
        Response.Expires = -1500;
        Response.CacheControl =无缓存;    }

when i click on logout button, everything will be fine after that click on back button of browser user does not enter or login ..thats also good.(but, no event click on master pages; working is good )

and, any event is clicked like search items (i mean using select query or fetch data through button click)

logout button working not good ...its work like normal page ;i.e. when i click on logout ...redirect to home page using Session.clear(); & Redirect.Response("page.aspx")

Use this code,behind master page page_load:

if (!IsPostBack)
        {

            if (Session["name"] == null)
            {

                Response.Redirect("Default.aspx");
            }

            else
            {

                Response.ClearHeaders();

                Response.AddHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate");

                Response.AddHeader("Pragma", "no-cache");

                Label1.Text = "WELCOME" + " " + Session["name"];


            }

now i want to disabling back button without using of javascript, because reason is when someone stop the javascript of browser ....same issues occurs..

解决方案

private void Page_Load(object sender, EventArgs e)
    {
        // Put user code to initialize the page here
        if (Session["SessionId"] == null)
        {
            Response.Redirect("Login.aspx"); 
        }


        Response.Buffer=true;
        Response.ExpiresAbsolute=DateTime.Now.AddDays(-1d);
        Response.Expires = -1500;
        Response.CacheControl ="no-cache";

    }

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

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