The Application object is scoped to the whole global, which means it is valid for all users. It is valid throughout the application life cycle, similar to using global variables, so it can be accessed from different pages. It differs from the session variable in that the former is a global variable shared by all users, and the latter is a unique global variable for each user.
One might ask, since all users can use the application variable, where can he use it? Here's an example: the number of site visits. It can be manipulated when multiple requests are accessed.
Pros: 1. Easy to use, consumes less server resources.
2. Not only can pass the simple data, but also can pass the object.
3. The size of the data volume is unlimited.
Cons: 1. It is easy to be manipulated as a global variable. Therefore, the variables used by individual users are generally not application.
How to use: 1. Create the name and value you need to pass in the code of the source page construct the application variable: application["Nmae"]= "Value (Or Object)";
2. The code on the destination page uses the application variable to remove the passed value. Result = application["Nmae"]
Note: The common lock and unlock methods are used to lock and unlock, in order to prevent concurrent modifications.
Indextest.aspx Background page:
1 Private void Btn_chuanzhi_click (object23 application[" name "] =4 }
Indextestlist.aspx Background page:
1 private void Page_Load (object sender, EventArgs e) Span style= "color: #008080;" >2 { 3 string name; 4 Application.Lock (); 5 name = Application[ " name ". ToString (); 6 Application.UnLock (); 7 }