Online active users counter in ASP.NET
Online active users counter in ASP.NET
With this tool which is written for ASP.NET, it is possible to count the number of online users, members and guest users in web sites.
Installation
The tool installation is very simple and only takes a few minutes.
Step one - Add Reference:
After downloading the attachment, you should add a reference to the project. If you know how to add references please skip this step.
To add the reference, right click on your solution and select "Add Reference" from the menu. Then select the "OnlineActiveUsers.dll" file. Now the reference is added to the solution.
Step two - Change configuration:
Open the "Web.config" file from your project (If this file is absent, right click on your project and from "Add new item", select "Web configuration file"). Then add this code on "web.config" file.
<httpModules>
<add name="OnlineActiveUsers" type="OnlineActiveUsers.OnlineUsersModule"/>
</httpModules>
Note that this code should be placed between "system.web" tags.
Step three - Add some code to global.asax:
Open the "global.asax" file in your project (If this file is absent, right click on your project and from "Add new item", select "Global Application Class"). In the "session_end" event add this code:
OnlineActiveUsers.OnlineUsersInstance.OnlineUsers.UpdateForUserLeave()
If the project is C# the result should be like this:
void Session_End(object sender, EventArgs e)
{
OnlineActiveUsers.OnlineUsersInstance.OnlineUsers.UpdateForUserLeave();
}
After now the tool will count user statistics.
Step four - Access the statics:
To get the statistics, refer to "OnlineActiveUsers.OnlineUsersInstance.OnlineUsers" variable.
Here are some of its important properties:
UsersCount: the number of all online users.
GuestUsersCount: the number of online guest users. This property works only if you have used SetUserOffline and SetUserOnline methods. These methods are explained below.
RegistredUsersCount: the number
Ïà¹ØÎĵµ£º
ÔÚ°²È«ÐÔÒªÇó²»ÊǺܸߵÄASP.Net³ÌÐòÖУ¬»ùÓÚFormsµÄÉí·ÝÑéÖ¤ÊǾ³£Ê¹ÓõÄÒ»ÖÖ·½Ê½£¬¶øÈç¹ûÐèÒª¶ÔWebService½øÐÐÉí·ÝÑéÖ¤£¬×î³£ÓõĿÉÄÜÊÇ»ùÓÚSoap ±êÍ·µÄ×Ô¶¨ÒåÉí·ÝÑéÖ¤·½Ê½¡£Èç¹û¶ÔÁ½Õß×öһϱȽϵĻ°£¬ÏÔÈ»£¬»ùÓÚFormsµÄÑéÖ¤·½Ê½¸ü¼Ó·½±ãÒ×Óã¬ÄÜ·ñ½«FormsÑéÖ¤·½Ê½Ó¦Óõ½WebServiceÖÐÈ¥ÄØ£¿
´ÓÀíÂÛÉ ......
AjaxÏÖÔÚÒѾÊÇÏ൱Á÷Ðеļ¼ÊõÁË£¬Ajax²»½öÊÇÏë·þÎñÆ÷¶Ë·¢ËÍÏûÏ¢£¬¸üÖØÒªµÄÊÇÎÞˢеÄÖØÔØÒ³Ãæ¡£
Èç¹ûÒ³Ãæµ¥´¿µÄʹÓÃjsÀ´´´½¨£¬ÒªÐ´´óÁ¿µÄ´úÂ룬¶øÇÒ²»Ö±¹Û¡£
ÔÚasp.netÖУ¬ÆäʵÎÒÃÇ¿ÉÒÔ´´½¨Óû§×Ô¶¨Òå¿Ø¼þ£¬Í¨¹ýAjaxÇëÇó·µ»ØÓû§×Ô¶¨Òå¿Ø¼þHTML´úÂë¡£
public static string RangerUsControl(string controlName) ......
Èç¹ûÄãÒѾÓн϶àµÄÃæÏò¶ÔÏ󿪷¢¾Ñ飬Ìø¹ýÒÔÏÂÕâÁ½²½£º
µÚÒ»²½¡¡ÕÆÎÕÒ»ÃÅ.NETÃæÏò¶ÔÏóÓïÑÔ£¬C#»òVB.NET ÎÒÇ¿ÁÒ·´¶ÔÔÚûϵͳѧ¹ýÒ»ÃÅÃæÏò¶ÔÏó(OO)ÓïÑÔµÄÇ°ÌáÏÂȥѧASP.NET¡£ ASP.NETÊÇÒ»¸öÈ«ÃæÏò¶ÔÏóµÄ¼¼Êõ£¬²»¶®OO£¬ÄǾø¶Ôѧ²»ÏÂÈ¥!
¡¡¡¡µÚ¶þ²½¡¡¶Ô.NET FrameworkÀà¿âÓÐÒ»¶¨µÄÁ˽⠿ÉÒ ......
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ͼƬ»¬¶¯.aspx.cs" Inherits="ASP.net.ͼƬ»¬¶¯" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  ......