Asp. NET cross-page pass-through values
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 that can be manipulated when multiple requests are accessed.
Advantages:
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.
Disadvantages:
1. It is easy to operate 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 source page code to 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:
Common lock and Unlock methods are used to lock and unlock, in order to prevent concurrent modifications.
Example:(1) a.aspx
private void Button1_Click (object sender, System.EventArgs e) {application["name"] = Label1.Text;}
(2) b.aspx
private void Page_Load (object sender, EventArgs e) {string name; Application.Lock (); Name = application["Name"]. ToString (); Application.UnLock (); }
Asp. NET cross-page pass value--application