ASP. NET Load the corresponding Load event and OnLoad method. For this event, I believe most of my friends will be familiar with it, using. the Page_Load method in the page generated by Net is the method for responding to the Load event. For each request, the Load event is triggered and the Page_Load method is executed. I believe most people know about ASP. net.
The Page_Load method responds to the Load event, which is in the System. web. webControl. the class defined in the Control class is the ancestor of Page and all server controls) and is triggered in the OnLoad method.
Many people may have encountered such a problem. They wrote a PageBase class and then verified the user information in Page_Load. The results showed that Page_Load on the subclass page is always executed no matter whether the verification is successful or not, this may leave some security risks. The user may execute the Page_Load method in the subclass without being verified.
The reason for this problem is very simple, because the Page_Load method is added to the Load event in OnInit, And the OnInit method of the subclass adds the Load event first, and then calls the base. onInit, which causes the Page_Load of the subclass to be added first and then executed first.
There are two ways to solve this problem:
1) Reload the OnLoad method in PageBase, verify the user in OnLoad, and then call base. onLoad, because the Load event is triggered in OnLoad, so that we can ensure that the user is verified before the Load event is triggered.
2) Call base. OnInit in the OnInit method of the subclass to ensure that the parent class executes Page_Load first.
The above describes the Page_Load method in ASP. NET.
- XML data displayed on the ASP. NET page
- What is iframe asp. NET?
- ASP. NET lifecycle display
- Solve the Problem of ASP. net ajax script errors
- ASP. NET Applications