By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,978 Members | 1,831 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,978 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.