且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我如何防止注销会话下的返回按钮

更新时间:2023-12-02 12:41:58

通常,注销过程会终止客户端和服务器端的会话,并且/或者清除会话的身份验证状态.如果要访问任何受保护的页面,则会重定向到登录页面.如果您对如何在ASP.NET中实现此方法感兴趣,只需使用Visual Studio中包含的经过表单身份验证的模板创建项目.
在这里,您有一个概述: http://msdn.microsoft.com/en-us/library/ff647070. aspx [^ ]

另一个考虑因素:后退按钮也与缓存有关.有了上述内容,后退"将显示缓存的页面.您需要禁用客户端缓存 [ ^ ],以确保可以从服务器重新加载页面,并且您可以重定向到登录页面.
In general the logoff process kills the session on client and server side, and/or clears the authenticated status of the session. If you want to access any protected page, you get a redirection to the logon page. If you are interested in how you can achieve this in ASP.NET, just create a project using the forms authenticated template included in Visual Studio.
Here you have an overview: http://msdn.microsoft.com/en-us/library/ff647070.aspx[^]

An other consideration: back button has also to do with caching. With just the above things "back" will show the cached page. You need to disable client side caching[^] to ensure page reload from server and you can redirect to logon page.


简单的答案是,不必依赖浏览器的后退按钮,在服务器端组件中实施逻辑以检查用户是否已通过身份验证,如果未通过验证,则重定向到登录"页面.
In simple way the answer is, don''t be depend on the browser''s back button, Implement logic in your server side component to check the user is authenticated or not , if not then redirect to Login page.


以下提示应有助于: ^ ]
Following tip should help: Browser back button issue after logout[^]