ASP.net 会员资格强制用户离线(作为管理员)
我正在寻找一种方法来破坏特定用户的 ASP.net 会员会话。我这样做的原因是作为管理员我想删除用户。这工作正常,但如果用户已经有一个活动会话,他仍然被标记为“在线”,直到该会话终止(我每次都使用 Current.User.Identity.IsAuthenticated 进行验证)。
如何根据授权用户终止会话。这样,当我执行 Memberships.DeleteUser(username) 时,我也可以执行 Sessions.KillByUser(username)
提前感谢
我最终遵循了他们的建议并使用以下方法,对于任何有相同问题的人: http://www.chillaxen.com/2011/02/asp-net-force-a-user-offline-as-admin-destroy-a-session-by-username/
I am looking for a way to distroy the ASP.net membership session for a specific user. The reason I am doing this is as an admin I want to delete a user. This works fine, but if the user already has an active session, he is still marked as "online" until this session dies (I verify each time by using Current.User.Identity.IsAuthenticated).
How do I go about killing a session based on the user it's authorized as. This way when I do Memberships.DeleteUser(username) I can also do Sessions.KillByUser(username)
Thanks in advance
I ended up following their suggestion and using the following method, for anyone who has the same issue:
http://www.chillaxen.com/2011/02/asp-net-force-a-user-offline-as-admin-destroy-a-session-by-username/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如何添加一个拦截 PostAuthorizeRequest 事件的 HttpModule :根据要“销毁”的 ID 的全局列表检查用户的凭据。如果存在匹配,则终止用户会话。
How about adding a HttpModule which intercept PostAuthorizeRequest event: Check the users' credentials against a global list of IDs you want to "destroy". If there's a match, kill the users session.
正如雅各布建议的或者你可以尝试这个......
在 Global.asax 中检查登录的用户是否在“要离线的用户列表”中,然后通过表单身份验证或删除 cookie 注销该用户。
As Jakob suggested Or you can try this...
in the Global.asax check if the logged in user is in the 'List of user to be made Offline' then logout the user by forms authentication or deleting the cookie.