In ASP. NET, how do events occur in sequence ?, ASP. NET event?
This article introduces the event execution sequence in ASP. NET through practical methods.
Method/step
Create a C # WebForm project, such:
Add a Button control in the Defualt. aspx file and name it "Button1". Then add an event handler for each event of the control and add a breakpoint, for example:
Open the Global. asax file and add breakpoints, such:
Open the code file Site. Master. cs of Site. Master and add breakpoints, such:
Run the code by running F5: Application_Start → Session_Start → button?init → Page_Load (Defualt. asp) → Page_Load (Site. Master) → button?load → button=prerender → button=unload → display interface.
When we disable IIS, run Session_End → Application_End.
Summary:
1. Execute the Application_Start function when you start a website through IIS and the Application_End function when you close the website. These two functions can be considered called by IIS.
2. When a new connection request arrives, the Session_Start function can be used. When the user does not operate for a long time and exceeds the Session duration, the Session_End function is executed. These two functions can also be viewed as called by IIS.
3. When requesting An aspx page, the Init function of all controls will be executed first, and then the Page_Load function of the page will be executed. If there is a motherboard, The Page_Load function of the motherboard will be executed again, then, execute the Load function, PreRender function, and Unload function of the control. After all the server controls execute these functions, the corresponding interface is displayed.
Now you have a rough idea about how events occur in ASP. NET in sequence, and hope to help you learn the sequence of event execution in Asp. Net.