如何限制用户登录? [英] How to limit users to Login?
问题描述
我正在使用asp.net4.0 webforms开发一个应用程序。我们需要限制登录某些限制:
- 一次只能有499位用户登录(意味着只有499位用户可以在线)
- 每当第500个用户尝试登录时,会出现消息用户登录超过,请稍后登录!。
是否有任何内置功能来计算用户数量?请注意,我们没有使用任何会员资格提供商,我们只是使用自定义安全的表单身份验证。
如果有人也提供asp中的解决方案将会很有帮助。 net webforms和asp.net MVC4 / 5.
I am developing an application in asp.net4.0 webforms. We need to restrict Login on certain limit:
- Only 499 users can able to login at a time (means only 499 users can be online)
- whenever 500th user try to login, there will be a message "User login exceeds, please login later!".
Is there any built-in feature to calculate number of users? Please note that we are not using any membership provider, we simply use Form-authentication with custom security.
It will be helpful if anyone also provide solution in both asp.net webforms and asp.net MVC4/5.
推荐答案
请阅读我的评论。
< u>第一种方式:
如果你使用IIS,你可以按照这里描述的方式限制连接数:限制网站< limits> [ ^ ]
第二种方式:
您可以收集有关连接数的信息。
这个想法是:当用户打开您的应用程序/站点时,它会检查已连接的用户数。如果连接数小于限制,则应用程序/站点允许用户使用它。如果连接数超过限制,则应用程序/站点不允许用户使用它。当用户离开应用程序/站点时,它必须记住这一事实以减少活动连接的数量。
因此,您必须创建一个数据库并编写方法来增加/减少活动连接的数量。
Please, read my comment.
First way:
If you use IIS, you can limit count of connections the way is described here: Limits for a Web Site <limits>[^]
Second way:
You can collect information about the count of connections.
The idea is: when user open your application/site, it checks how many users is already connected. If the count of connection is less than limit, application/site enables user to use it. If the count of connection exceeds the limit, application/site does not allow user to use it. When a user leaves application/site, it must 'remember' this fact to decrease the number of active connections.
So, you have to create a database and write methods to increase/decrease the count of active connections.
这篇关于如何限制用户登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!