Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted
Comments
Dimitri Nostarik 25-Oct-14 16:49pm    
Simply adjust your server by increasing an integer of connections when a connection is made, and decreasing an integer when a connection is lost? Then, if the integer exceeds a certain amount forcibly close the connection after showing a message?
Maciej Los 25-Oct-14 17:24pm    
Depends on web server...

1 solution

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.
 
Share this answer
 
v2
Comments
Gaurav Aroraa 26-Oct-14 5:38am    
Thanks Maciej - this is a good solution but unfortunately, its not working in our scenario. I will find-out why? Between, I am accepting your solution :)
Maciej Los 26-Oct-14 5:59am    
Thank you ;)
I updated my answer.
Gaurav Aroraa 26-Oct-14 6:01am    
Great stuff man! It will definitely save my hundred hours (y)
Maciej Los 26-Oct-14 6:04am    
Thank you ;)
Gaurav Aroraa 30-Oct-14 2:12am    
We have found another way, I will be posting the same as an article so, others can also get benefited.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900