表单认证
我需要问: 我在 ASP.NET 应用程序中使用表单身份验证。
但是当我在用户登录后发布网页时,如果他没有注销,他只是关闭浏览器,之后他再次浏览它,它将把他重定向到默认页面。 即使他没有注销,我如何强制将他重定向到登录页面?
I need to ask:
I use Forms Authentication in my ASP.NET application.
but when I publish the web after the user login, if he didn't signout he just close the browser and after that he browse it again it will redirect him to default page.
How can I enforce redirecting him to the login page even if he didn't sign out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该看到此处指定的表单身份验证文档。每当您想要设置超时属性时,您都可以强制 cookie 过期。此外,您根本无法通过使用 cookieless 属性来使用 cookie。还有其他可能对您有用的可选属性,但可能与您的问题无关。
You should see the documentation for forms authentication specified here. You can force the cookies to expire whenever you want setting the timeout attribute. Also, you could not use cookies at all by using the cookieless attribute. There are other optional attributes that could be useful for you, that might not be related to your question as well.
这将取决于他们的 asp.net 会话 ID cookie 是否仍然存在,或者他们是否启用了 cookie。要强制重定向到登录页面,您需要了解如何在浏览器关闭时使 cookie 丢失。根据我的经验,这无论如何都是默认行为。
It will depend on whether or not their asp.net session id cookie still exists, or whether they have cookies enabled at all. To enforce redirecting to the login page you will need to find out how to make the cookies be lost when the browser is closed. In my experience this is the default behaviour anyway.
我建议您检查 asp.net 会员、配置文件和角色提供程序,用于专门管理用户登录名、密码及其配置文件。
这是其中之一Scott Gu 的优秀文章,当您想要使用会员资格和个人资料时,应该添加书签。
I will suggest you to check asp.net Membership,Profile and Role provider for specifically manage user Logins, Passwords and their profile.
This is one of the good articles from Scott Gu, you should bookmark when you want to work with Membership and Profiles.