注销时返回按钮的问题. [英] BACK button issue while logout.

查看:57
本文介绍了注销时返回按钮的问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

单击后退"按钮后,它将重定向到登录窗口,如果我单击后退"按钮,则浏览器将转到上一页,我使用c#清除了asp.net中所有变量的会话,并添加了以下几行要清除高速缓存,请转到上一页,请非常紧急.

After click the back button , it redirects to login window, if i click the back button the browser it goes to the previous page, I cleared the session for all the variables in asp.net with c#, and added the following lines to clear cache still it goes to the previous page, please help it very urgent

推荐答案

可以使用多种方法来避免这种情况.最好且安全的方法是在页面加载中检查会话值.如果存在,请使用其他功能将其重定向到登录页面.
There are different approaches to avoid this. The best and secured approach is on page load check the session value. If it exists go with functionality other wise redirect to the login page.
if (!string.IsNullOrEmpty(Convert.ToString(Session["username"])))
        {
            //continue logic
        }
        else
        {
            Response.Redirect("login.aspx");
        }


在注销链接按钮中编写此代码

write this code in logout link button

Session.Abandon();
       Response.Write("<script>window.top.navigate('../login.aspx')</script>");



上面的脚本禁用了Internet Explorer的后退按钮

否则你可以这样写
在Page_Load事件的每个页面中



the above script disables the back button of the internet explorer

or else you can write like this
in each page in Page_Load event

protected void Page_Load(object sender, EventArgs e)
    {
        if (Session.Count > 0)
        {
            //show this page
        }
        else
            Response.Redirect("Login_page.aspx");
    }



希望这会对您有所帮助



Hope this will help you


尝试使用javascript方法:

<head></head>部分中,添加以下javascript代码:

Try the javascript method:

In the <head></head> section add the following javascript code:

<script type="text/javascript" language="javascript">
function noBack()
{
window.history.forward()
}
noBack();
window.onload=noBack;
window.onpageshow=function(evt){if(evt.persisted)noBack()}
window.onunload=function(){void(0)}
</script>


使用以下命令调用此函数:


call this function using:

body onload="noBack();



来源: http://forums.asp.net/t/1452128.aspx/1 [ ^ ]



source:http://forums.asp.net/t/1452128.aspx/1[^]


这篇关于注销时返回按钮的问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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