[英]Reload the web page on pressing browser back button after logout in c# .net
I am working on the bus ticket reservation system. 我正在开发公交车票预订系统。 I have developed all the login scenarios for all actors on role base access. 我已经为所有基于角色访问的参与者开发了所有登录方案。 All the actors login via login page and login page redirects them to their permitted home pages. 所有演员都通过登录页面登录,登录页面会将他们重定向到允许的主页。 Now the user session has get started and after completing the required tasks, presses logout button and this logout button does: 现在,用户会话已开始,并在完成必需的任务后,按注销按钮,此注销按钮将执行以下操作:
Session.Abandon();
Response.Redirect("default.aspx");
After that, the user is on default login page but when the user presses the browser back button the same home page remains showing in the window until he or she refresh the home page manually. 此后,用户进入默认的登录页面,但是当用户按下浏览器的“后退”按钮时,该主页仍显示在窗口中,直到他或她手动刷新主页为止。 home page code is: 主页代码为:
if(Session["user"] != null)
{
//welcome user
}
else
{
Response.Redirect("../Default.aspx");
}
I want to refresh the home page on pressing browser back button that the user no longer see the page after the logout. 我要刷新主页,方法是按浏览器后退按钮,使用户注销后不再看到该页面。 how we can do this work in c# .net? 我们如何在c#.net中完成这项工作?
You can do it in Javascript something like this 您可以在Javascript中执行以下操作
<body onbeforeunload=”HandleBackFunctionality()”>
function HandleBackFunctionality()
{
if(window.event)//For IE
{
if(window.event.clientX < 40 && window.event.clientY < 0)
{
location.reload();
}
else
{
alert("Browser refresh button is clicked...");
}
}
else//For other browsers
{
if(event.currentTarget.performance.navigation.type == 1)
{
alert("Browser refresh button is clicked...");
}
if(event.currentTarget.performance.navigation.type == 2)
{
location.reload();
}
}
}
you want to disable caching on the "secure" pages so when someone logs out and click the back button (or history) they will not see the browser cached version of it... 您想在“安全”页面上禁用缓存,因此当有人注销并单击“后退”按钮(或历史记录)时,他们将看不到它的浏览器缓存版本...
See how to do that in this post: How to handle form submission ASP.NET MVC Back button? 请参阅本文中的操作方法: 如何处理表单提交ASP.NET MVC的“后退”按钮?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.