Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Online Users on ASP.NET Application

Saw so many articles and links related to the same concept.

Counting online users using asp.net

Is there any ASP.NET application to monitor online user and page view log report?

Mine is little different. My application is MVC4 and using SimpleMembershipProvider. I am not sure why GetNumberOfUsersOnline is not working.

https://msdn.microsoft.com/en-us/library/system.web.security.membership.getnumberofusersonline(v=vs.110).aspx

Any Ideas ? How to do this in a easy and efficient way. I am just using this in only one place in my website.

like image 501
Chatra Avatar asked Oct 13 '15 01:10

Chatra


People also ask

Is ASP.NET good for websites?

When it comes to . NET Core, it's the best framework for web development. With the development of ASP.NET Core, Microsoft has addressed a lot of questions with one shot. It allows developers to develop web apps, web services, mobile backend, and many other things under a single framework.

Is ASP.NET used for web application?

ASP.NET is a free web framework for building great websites and web applications using HTML, CSS, and JavaScript. You can also create Web APIs and use real-time technologies like Web Sockets.

Is ASP.NET support cross platform?

ASP.NET is an open source web framework, created by Microsoft, for building modern web apps and services with . NET. ASP.NET is cross platform and runs on Linux, Windows, macOS, and Docker.


2 Answers

I found this online it it looks like it will work for you. Just add this code to your Global.asax.cs file:

protected void Application_Start(Object sender, EventArgs e)
{

    Application.Lock();
    Application["UserCount"] = 0;

}
protected void Session_Start(Object sender, EventArgs e)
{

    Application.Lock();
    Application["UserCount"] = (int)Application["UserCount"] + 1;
    Application.UnLock();
}

protected void Session_End(Object sender, EventArgs e)
{
    Application.Lock();
    Application["UserCount"] = (int)Application["UserCount"] - 1;
    Application.UnLock();

}

Then when you need to access the user count you can use:

var count = (int)Application["UserCount"];
like image 107
Aaron Avatar answered Sep 17 '22 11:09

Aaron


You can use signalR to track connected users. Using this you can get count online efficiently & Real Time and also track connected users information. You can put condition to track logged in users also. So, Go with latest technology. You can implement with existing MVC application.

You can refer this official tutorial for the same.

http://www.asp.net/signalr

like image 25
Kishan Choudhary Avatar answered Sep 21 '22 11:09

Kishan Choudhary