ASP. NET status management provides an important mechanism for session: http://www.cnblogs.com/zhaozhan/archive/2009/06/24/1509854.html.
ASP. NET provides another object application to manage applications.ProgramInformation stored in an application object in ASP. NET applications are static during all connections, and the information in the application object is also stored as a hash of name-value pairs.
The best place to set the application value is in the application_start event handler in the global. asax file. This event is triggered every time the application is started for the first time. This event is only triggered once in the lifecycle of the Web application and will not be triggered in subsequent web user requests, the application or IIS is stopped.
The application can directly use the key or index of the application. For example, application ["Usercount"] = 0;
To ensure data integrity, you must lock and unlock the application object. Because multiple instances of the application may update the value at the same time, lock and unlock the Application Object using the lock () and the unlock () method.
Application. Lock ();IntUsercount = (Int) Application ["Usercount"]; Usercount + = 1; application ["Usercount"] = Usercount; application. Unlock ();
However, using these two methods is also a loss of performance, because any other ASP.. NET application instance is basically blocked when waiting for the Application object to be unlocked to access it. Therefore, if you use the application object in read/write mode, make sure that the minimum numberCode. It is unwise to separate other threads in the lock or query with a long running time.