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中设置你所需要的文化。参见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. ...
我试过 beginrequest, 但是不行。我想原因是因为page.request在此之后才被创建或赋值,所以在beginrequest中设置的文化会被覆盖了。直到 10. postacquirerequeststate,才被准备好,只有在此之后我们才可以设置所需要的文化。 11和12之间的 "the event handler is executed."就应该是整个页面的生命周期的处理了。方法一使用initializeculture就是在这里。