The http protocol is stateless and does not remember what happened on the previous page ". The server does not remember what the browser gave last time. The Browser needs to remember these values (input is recorded in value, and other values are placed in hidden fields, such as viewstate ), the next time I submit the application, I will send it to the server to achieve interaction! Disadvantages of storing status information in hidden fields: increasing website traffic, reducing access speeds, and placing confidential data in a form may cause data spoofing security issues! Therefore, the Session and Cookie mechanisms are generated to supplement this. Let's look at the following small example:
View Code
Public partial class WebForm1: System. Web. UI. Page
{// If a request is not accepted, a new WebForm1 object will be processed and released after processing. Therefore, each request is a new page object.
Private int I = 0;
Protected void button#click (object sender, EventArgs e)
{
I ++; // Q: Will the printed value automatically increase when I click the button? No. Each time it is 1.
Response. Write (I. ToString ());
}
Protected void Page_Load (object sender, EventArgs e)
{
}
}