473,545 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1787
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**@discussio ns.microsoft.co m> 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
17265
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 prohibit a user to log in twice. A was thinking about setting some flag in the db, but in that case i need some timeout in case a pc can crash for...
4
3245
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 current session. The problem is that the server does not know when the current session expires. (I have quite long timeouts.) Did anybody attempt...
12
2506
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 to store a logged in token. With only basic knowledge of sessions I assumed there was some kind of default time before the session data is...
4
2023
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 the web app I am using asp.net/vb.net This means Customer Group A, could only have 3 concurrent users logged in, and for Customer Group B only 30 at...
8
1850
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 all sessions. Has anyone else figured this out? Thanks in advance, Vince
5
3533
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 Application("numberOfVisitors"). It works fine but when I compare values to number of ASP Applications "Sessions Active" under Windows 2003...
2
2324
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 sessions and the high water mark. My monitoring has revealed a few interesting things. 1. The ASP application is being shutdown and restarted almost...
9
1335
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 that I can go through an array of users. Is that possible or is it against the whole spirit of sessions? mm? Hughie
8
3731
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 bool field to the table and set each user to 1 if they are logged in, and 0 if they are not logged in? *** Sent via Developersdex...
0
7490
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7682
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7935
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6009
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5069
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3465
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.