473,378 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Limitting Number of Logged in Users or Active Sessions in ASP.NET

Hello,

This requirement might seem strange to someone out there, but here it's

We need to make sure only certain number of users can be logged in the site
at the same time. Is there any way to do that in ASP.NET, in web config file
or otherwise. Thanks in advance for your help.
Nov 18 '05 #1
2 1775
It's a difficult task. You could increment a counter when someone
successfully logs in, but they might never log off - they might just
close the browser. In these cases the best you can do is assume a user
has logged off after a period of time (say 5,10,20 minutes) when you
have not seen a request from them. Still - it might prevent other
users from getting in even though someone else has left the site.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 18 Oct 2004 19:31:02 -0700, "Lenn"
<Le**@discussions.microsoft.com> wrote:
Hello,

This requirement might seem strange to someone out there, but here it's

We need to make sure only certain number of users can be logged in the site
at the same time. Is there any way to do that in ASP.NET, in web config file
or otherwise. Thanks in advance for your help.


Nov 18 '05 #2
Hi Lenn,

You can take a look to the Session_OnStart and Session_OnEnd of the
global.asax. The problem is that you can count all the started sessions, but
is very difficult to tell which of them are active. In order to have a better
idea of this, you can also hook to the BeginRequest event and check when the
last request of a given section happened. Within this you can get an
aproximate measure of the amount of users using your site (you can know
exactly the number of sessions started, but some of them may be abandoned or
inactive, waiting for its timeout, e.g the client closed the browser).

Anyway, is very difficult to be deterministic about this issue, specially
because the inherent statefullness of http, but with this techinques you can
get an approximate value (with an error margin). Another sugestion would be
to make some calculations and have a "safe-guard" number of sessions, which
will allow you to deal with the unused but active sessions.

Here you can find some info about global.asax...

http://msdn.microsoft.com/library/de...alasaxfile.asp

http://samples.gotdotnet.com/quickst...lobalasax.aspx

Regards,
Leon

"Lenn" wrote:
Hello,

This requirement might seem strange to someone out there, but here it's

We need to make sure only certain number of users can be logged in the site
at the same time. Is there any way to do that in ASP.NET, in web config file
or otherwise. Thanks in advance for your help.

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: fr? | last post by:
Hi, i have a website , on wich users have to log in credentials are checked against mysql db some session vars are set during login for use somewhere else in the code. Is there a way to...
4
by: vesely | last post by:
Hi all, I'm currently relying on logged-in users hitting "logout" (logoff) before they leave, in order to terminate the session. With PHP the session filename is in a cookie that lasts for the...
12
by: Dave Smithz | last post by:
Hi there, Users of my PHP DB application have complained that it seems to log them out every now and then. I actually assume this is when it has been idle for sometime as I use session variables...
4
by: Adam | last post by:
Greetings, I am creating a web application, which I will be selling licenses to be able to use it. So Customer Group A, could purchase 3 licenses, Customer Group B could purchase 30. With...
8
by: Vince Varallo | last post by:
Hello All, I would like to display all logged on users on a web page. I store each user's name in a session varible, but I don't seem to be able to loop through a sessions collection to view...
5
by: TheOne | last post by:
Hi I am trying to display on a web page number of visitors on the site. I am doing this by increasing +1 in global.asax on Session_start and subtracting -1 on Session_end. I am storing value in the...
2
by: tbone | last post by:
In trying to improve the throughput of a classic ASP app I wrote last year, I added monitoring to the application and session start and end methods. For one, I'm counting the total number of...
9
by: hughie | last post by:
Anyone know a way to have a site list the usernames of those logged in? It could be done by writing to a db when a session is started and ended but it would be nicer if there is some global session...
8
by: Mike P | last post by:
What would be the best way of counting the number of users who are currently logged on to a website? I am making the users login against a database of valid users. Would the best way be to add a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.