Examples of Application global object usage in ASP. NET, asp. netapplication
The example in this article describes the Application global object usage in ASP. NET. Share it with you for your reference. The details are as follows:
Application is the Global Object of the Application and is shared by all users. No matter which page is used to operate the Application, the other page can read the Application information.
Because the Application is shared, it is locked before the operation, and then unlocked after the operation is completed.
Set Data on a page:
Application. Lock (); Application. Set ("address", "Shanghai"); Application. UnLock ();
Retrieve Data on another page:
String s = (string) Application. Get ("address"); Button1.Text = s;
Add a "Global application class" Global. asax. Execute Application_Start when the first page of the application is accessed.
For example, "count the number of accessors", Application_BeginRequest will execute the number of users when the previous content on the server is accessed. Why is this not good? High-concurrency access will be very slow!
Note: Do not use an Application for website development, and rarely use it.
I hope this article will help you design your asp.net program.