用户点击导航栏(浏览器)时如何终止会话

人气:678 发布:2022-09-22 标签: c# ASP.NET4 C#4.0

问题描述

亲爱的所有人, 在我的应用程序中,当用户点击返回按钮时,所有会话都被终止,但用户点击了浏览器的导航栏,因此会话不会被杀死。 任何机构都可以提供帮助我的想法

Dear All, In My Application when user clicks on Back button then all sessions are killed,but users are clicking on Navigation bar of browser so sessions are not killed. can any body gives idea which helps me

推荐答案

添加以下代码片段......希望它有所帮助!! Add following code snippet.....hope it helps !!
<script type="text/javascript">
window.history.forward();   
function noBack() 
{ window.history.forward(); } 
</SCRIPT> 
</HEAD> 

<BODY onload="noBack();"     
onpageshow="if (event.persisted) noBack();"  onunload=""> 
</script>

试试这个, Try this ,
protected void Back_button_click(object sender, EventArgs e)
    {
        Session.RemoveAll();
        Response.Redirect("pathOf_Page");

        
    }

了解更多信息留下你的评论。

for more information left your comment.

879