Configure the session status as follows: < Sessionstate Mode = " Inproc " > </ Sessionstate >
Select "Add new item" in the project, add the "Global. asax" global variable file, and modify the session_start and session_end methods; Code As follows: Void Session_start ( Object Sender, eventargs E)
{
// Code that runs when a new session is started
Session. Timeout = 5 ; // Set the validity period of the session, which can be modified as needed.
Application. Lock ();
Application [ " Zzzonline " ] = Convert. toint32 (application [ " Zzzonline " ]) + 1 ;
Application. Unlock ();
}
Void Session_end ( Object Sender, eventargs E)
{
// The code that runs when the session ends.
// Note: Only the sessionstate mode in the web. config file is set
// In inproc, The session_end event is triggered. If the session mode is set to StateServer
// Or sqlserver.
Application. Lock ();
Application [ " Zzzonline " ] = Convert. toint32 (application [ " Zzzonline " ]) - 1 ;
Application. Unlock ();
}
This can be called on the. ASPX page;
< ASP: Label ID = " Label1 " Runat = " Server " > Currently online & Nbsp; < Font color = Red > <% = Application [ " Zzzonline " ] %> </ Font > & Nbsp; person </ ASP: Label >
From: http://www.cnblogs.com/xiaopeng84/archive/2007/01/23/627630.html