FormsAuthentication.SignOut 未按预期工作
我在我的 ASP.NET Web 应用程序中使用表单身份验证。当用户单击“退出”按钮时,我执行以下代码:
FormsAuthentication.SignOut();
FormsAuthentication.RedirectToLoginPage();
它有效。问题是,在注销之前,如果我复制当前所在的受限页面的 URL,然后注销,我可以将该 URL 粘贴回浏览器并返回受限页面,绕过登录页面。
我的网络配置如下所示:
<authentication mode="Forms">
<forms name="NoiseAdvisor" loginUrl="~/Login.aspx" timeout="20" slidingExpiration="true" cookieless="AutoDetect" protection="All" requireSSL="false" defaultUrl="~/Restricted/Home.aspx"/>
</authentication>
我缺少什么吗?
I'm using Forms authentication in my asp.net web app. When the user clicks the 'sign out' button, I execute the following code:
FormsAuthentication.SignOut();
FormsAuthentication.RedirectToLoginPage();
which works. The problem is, before signing out, if I copy the url of the restricted page that I'm currently on, then sign out, I can paste the URL back into the browser and return to the restricted page, bypassing the login page.
My web config looks like this:
<authentication mode="Forms">
<forms name="NoiseAdvisor" loginUrl="~/Login.aspx" timeout="20" slidingExpiration="true" cookieless="AutoDetect" protection="All" requireSSL="false" defaultUrl="~/Restricted/Home.aspx"/>
</authentication>
Is there something I'm missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您能否确认该页面没有被您的浏览器缓存并且您实际上看到的是缓存版本?按 Shift-F5 并查看页面是否刷新或者是否重定向到登录页面。如果是这种情况,您可以使用缓存设置来确保用户无法返回该页面。
Can you confirm that the page is not cached by your browser and you are actually seeing a cached version? Press Shift-F5 and see if the page refreshes or if you are redirected to the login page instead. If that is the case, you can play with the cache settings to make sure users cannot go back to the page.
当您将 URL“粘贴”到浏览器中时,它将为您提供该页面的缓存版本(与您上次访问的视图相同),除非您明确禁用该页面的客户端缓存。正如 cdonner 提到的,按 Shift+F5,我猜它会将您踢到登录页面。
When you "paste" a URL into your browser, it is going to give you a cached version of the page (same view as your last visit) unless you've explicitly disabled client caching for the page. As cdonner mentioned, press Shift+F5 and I'm guessing it will kick you to the login page.
您是否检查过以确保正确限制页面?
如:
或者,您可以在受限页面上物理查看:
Have you checked to make sure you're restricting the page correctly?
Such as:
Or, you can physically check on the restricted page:
这对我有用
This works for me