once the http page handler class is fully identified, the asp.net run time calls the handler's processrequest method to process the request. ... (it) begins by calling the method frameworkinitialize, which builds the controls tree for the page. the method is a protected and virtual member of the templatecontrol class - the class from which page itself derives. any dynamically generated handler for an .aspx resource overrides frameworkinitialize. in this method, the whole control tree for the page is built.
next, processrequest makes the page transit various phases: initialization, loading of view state information and postback data, loading of the page's user code and execution of postback server-side events. after that, the page enters in rendering mode: the updated view state is collected; the html code is generated and then sent to the output console. finally, the page is unloaded and the request is considered completely served.
方法二。在prerequesthandlerexecute中設(shè)置你所需要的文化。參見(jiàn)httpapplication類的在線幫助: an application executes events that are handled by modules or user code that is defined in the global.asax file in the following sequence: 1. beginrequest 2. authenticaterequest 3. postauthenticaterequest 4. authorizerequest 5. postauthorizerequest 6. resolverequestcache an event handler (a page corresponding to the request url) is created at this point. 7. postresolverequestcache 8. postmaprequesthandler 9. acquirerequeststate 10. postacquirerequeststate 11. prerequesthandlerexecute the event handler is executed. 12. postrequesthandlerexecute 13. ...
我試過(guò) beginrequest, 但是不行。我想原因是因?yàn)閜age.request在此之后才被創(chuàng)建或賦值,所以在beginrequest中設(shè)置的文化會(huì)被覆蓋了。直到 10. postacquirerequeststate,才被準(zhǔn)備好,只有在此之后我們才可以設(shè)置所需要的文化。 11和12之間的 "the event handler is executed."就應(yīng)該是整個(gè)頁(yè)面的生命周期的處理了。方法一使用initializeculture就是在這里。