473,385 Members | 1,736 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,385 software developers and data experts.

Active User count in ASP .Net/C# application

29
Hi,

How can we get tthe number of active users connected to our web application.


I have added application varible that gets incrimeted at session_start and then is decreased at session_end


void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started

Application.Lock();
Application["TotalUsers"] = Convert.ToInt32( Application["TotalUsers"].ToString()) + 1;
Application.UnLock();


}

void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.

Application.Lock();
Application["TotalUsers"] = Convert.ToInt32(Application["TotalUsers"].ToString()) - 1;
Application.UnLock();

}

but the count keeps on increasing ...

i get the total users but not the total ACTIVE USERS


thanks
May 23 '08 #1
4 5488
shweta123
692 Expert 512MB
Hi,

This problem is coming may be because your session_end procedure is not getting called. So if you want to execute the code in session_end procedure then you have to call Session.Abandon() method when user Logs out from the web application.

Hi,

How can we get tthe number of active users connected to our web application.


I have added application varible that gets incrimeted at session_start and then is decreased at session_end


void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started

Application.Lock();
Application["TotalUsers"] = Convert.ToInt32( Application["TotalUsers"].ToString()) + 1;
Application.UnLock();


}

void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.

Application.Lock();
Application["TotalUsers"] = Convert.ToInt32(Application["TotalUsers"].ToString()) - 1;
Application.UnLock();

}

but the count keeps on increasing ...

i get the total users but not the total ACTIVE USERS


thanks
May 23 '08 #2
Frinavale
9,735 Expert Mod 8TB
Hi,

This problem is coming may be because your session_end procedure is not getting called. So if you want to execute the code in session_end procedure then you have to call Session.Abandon() method when user Logs out from the web application.
Also, please note that the Session_End is only called if you are using InProc Session....

-Frinny
May 23 '08 #3
tim007
29
But this is not fired if the user just closes the browser ... session_end is not called when the user just closes the browser.

if 5 users are connected and two of them just close the browsers

the Count would still be 5 where as it should have been 3...

we wont get the correct count of connected users
May 27 '08 #4
Plater
7,872 Expert 4TB
But this is not fired if the user just closes the browser ... session_end is not called when the user just closes the browser.
Then you will have to detect when the browser is closing.
There have been a number of threads here discussing how to do that.
May 27 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: huzz | last post by:
I have web application that quaries the Active Directory to get user details.. everything works fine but someday I'll get System.Runtime.InteropServices.COMExection and if I restart the client...
0
by: Ireneus Broncel | last post by:
I have a class which reads Groups and Users from ActiveDirectory. The Problem is, that i have about 10000 rows as product. When I am trying to read the "memberOf" Objects out of this field i get...
9
by: Patrick | last post by:
I have an ASP.NET page that searches for someone in the corporate Active Directory. It had been working fine until recently when I changed from Basic Authentication on IIS6 back to Integrated...
1
by: tangus via DotNetMonster.com | last post by:
Hello all, I'm really struggling with getting some Active Directory code to work in ASP.NET. Can you please provide assistance? I am executing the following code: Dim enTry As DirectoryEntry =...
1
by: Lucky | last post by:
hi guys, after long long efforts i got access to the active directory for "Intigrated windows authentication". now i', suppose to get access the network resources. the problem is i'm getting...
3
by: Brian McCullough | last post by:
Hello, I am trying to query ADAM using the ActiveDirectoryMembershipProvider in my ASP.NET 2.0 application, but have been unsuccessful. I have followed the steps in these blog posts, but still...
1
by: navaneethkn | last post by:
Hello I need to count how many users are active in the website. Do you have any idea on this. I did using application variable. On session_start event in global.asax I am incrementing the...
1
by: htperth | last post by:
Hi all, Note that I'm new to LDAP and Active Directory and am writing an application that retrieves a simple phone list for all the users in our domain. So far I have the following console app...
1
by: htperth | last post by:
Hi all, Note that I'm new to LDAP and Active Directory and am writing an application that retrieves a simple phone list for all the users in our domain. So far I have the following console app...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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,...
0
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...

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.