Asp.net中每个UserID仅一次并发登录 [英] Only one concurrent login per UserID in Asp.net

查看:89
本文介绍了Asp.net中每个UserID仅一次并发登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Asp.Net Web应用程序中每个用户仅允许一个并发登录?

我正在一个Web应用程序上工作,我要确保该网站一次只允许每个UserID一次登录.如果具有相同UserId的用户已经登录了应用程序,则不允许同时登录.

如何检查当前用户是否已经登录.我需要使用哪种状态管理技术(例如会话,缓存或应用程序,数据库)?

在以下情况下如何重置或删除状态管理中的值:

1.一旦用户注销

2.用户直接关闭浏览器而不注销

3.用户只需更改url即可导航到另一个站点

能不能请你指导我.

谢谢.

Is it possible to allow only one concurrent login per user in Asp.Net web application?

I am working on one web application in which i want to make sure that website allow only one login per UserID at a time .If the user with same UserId already logged in the aplication should not allow concurrent login.

How to check that current user already logged in or not.Which state management technique I need to use like session,cache or application,DB?

How to reset or remove value in state manegement when:

1.once user loggs out

2.User directly closes browser without log out

3.User nevigates to another site by just changing url

Can you please guide me on the same.

Thanks.

推荐答案

请看看
每个用户一次登录 [> limit-only-one-session-per-user-in- asp-net [ ^ ]
Please have look
One login per user[^]

limit-only-one-session-per-user-in-asp-net[^]


只需做一件事.在数据库的用户表中,添加一个称为IsLoggedin的位字段.用户登录时检查真值或假值.如果值是true(即已经登录),则将自动重定向到主页.并且如果value为false(未登录),则将该值更新为true,然后重定向.
请参考
[ ^ ]

您需要在此使用会话管理.将用户名存储为sessionID变量.
Abandon方法应类似于Session.Abandon();
如果要从会话中删除特定项目,请使用Session.Remove("YourItem");
如果您使用这种数据库方法来跟踪用户登录状态,请在结束会话后将标志再次设置为0(注销).

希望对您有所帮助:)
Just do one thing. In your database, in your usertable, add one bit field called IsLoggedin. when user login check for true or false value. If value is true(i.e. already logged in), then automatically redirect to home page. and if value is false(not logged in), then update that value to true, and redirect.
Refer this
[^]

You need to use session management in this. Store the username as sessionID variable.
the Abandon method should work like Session.Abandon();
If you want to remove a specific item from the session use something like Session.Remove("YourItem");
And if you are using this Database approach to track User login status, after ending session, set the flag to 0(logged out) again.

Hope it helps :)


请参阅此链接,可以解决您的问题:-
http://geekswithblogs.net/Frez/articles/preventing- a-user-from-having-multiple-concurrent-sessions.aspx [
refer this link which can be solved your problem:-
http://geekswithblogs.net/Frez/articles/preventing-a-user-from-having-multiple-concurrent-sessions.aspx[^]


这篇关于Asp.net中每个UserID仅一次并发登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆