且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何限制用户登录?

更新时间:2023-12-01 17:15:52

请阅读我的评论。



第一种方式:

如果你使用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.