Summary and collection of several recent ASP. NET development experiences (1)

Source: Internet
Author: User
I. Reasons for executing page_load event and page. ispostback twice on the page.
Cause 1:
When <% @ page .... if there is no autoeventwireup definition in, page_load will be executed twice. If there is a definition and the value is true, dynamically binding controls in ispostback also causes two page load events .. therefore, we recommend that you do not ignore autoeventwireup and set it to false;
Cause 2:
If the page contains , page_load may also be executed twice. Solution: I do not know.

Ii. oninit and onload
Personal Understanding: if the view is disabled on the page or the view is not used in the logic process or data is not necessary to be sent back, you can directly rewrite the onload method, instead of writing the oninit method, because oninit () then, some operations on the view method and the processing of the returned data will be performed. therefore, the onload efficiency is higher.

3. The Remote Server Returns Error 500.
During the process, you need to download the file from the remote server to the local device. You can directly report the Error 500 returned by the remote server. Check the error and the result is incorrect:
Cause: the page is saved in ANSI encoding, while the local full path contains Chinese characters, so the path cannot beProgramEffective identification.
Solution: Change the page encoding to UTF-8. You can use the advanced save option in the vs series.

4. Problems Caused by response. End, response. Redirect, etc.
If it is response. end (), available httpcontext. current. applicationinstance. completerequest () to replace (according to my personal test, it seems that after this sentence is used, no program can be executed later, or else it will continue to be executed ?)
For response. Redirect (), its overload method can be used: Response. Redirect (string, bool)
Of course, server. Execute () and server. Transfer () are similar.

Attaches the lifecycle of ASP. NET pages (you can see why you only need onload instead of oninit)
____
1. initialize init: Initialize the object-init event (oninit method)
Ii. Load view status: loadviewstate Method
3. process the returned data: loadpostdata method-in fact, this step is only loaded, and no other processing is performed.
--- The control implementing this method must inherit from the ipostbackdatahandler interface, which has two methods: loadpostdata and raisepostbackdatachangedevent.
4. Load: --- load event (onload method) --- all objects in this process have been instantiated ..
5. Send a change notification: raisepostbackdatachangedevent Method
6. process the send-back event: raisepostbackevent method of the ipostbackeventhandler interface.
7. Pre-rendering: onprerender method (prerender event)
8. Save view status: saveviewstate Method
9: Rendering: render method (-- no corresponding events exist)
10. Disposal and Resource Recycling: dispose method
Eleven: unload: Unload event (onUnload method )..
--------- Page is inherited from control, so it is also a special control!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.