utilitaire Posted August 2, 2005 Posted August 2, 2005 Here's the problem: I have a webform with many usercontrols. Those controls override the OnInit method, and the OnLoad method. The code runs fine, but I have some problem synchronizing all this. I have a certain routine I would like to execute each time a page is called by a client. This routine has to be done before ANY usercontrol is Init or Loaded. The question is: how do I do that? Where do I have to put the code in order to be sure It will be called before ANY other code? I tried in the «Init()» method of the main Page. It doesn't work since this «init» method is called after all controls in the page are called. Here's the scenario: 1) A client make a request. 2) The Page checks if the language in the URL (http://www.mysite.com/en/) is valid. My valid languages are "en" and "fr". If any other languages are specified, I redirect the client to a valid default language. 3) After the redirection, the new page (the good one) is executed, with all the controls in it. The «init» method is called for all controls, etc. I want to make sure the step 2 is executed before step 3. I'm sure you faced this kind of problem. Any suggestion? PS: Dont suggest me to do that in the global.asa, since the session_onstart method is only called once, and not each time the client make a new request for a page. Quote
wayneph Posted August 2, 2005 Posted August 2, 2005 I'm going to suggest global.asax, but not the Session sub. Can you do it as part of the Begin Request? This fires each and everytime a page from the application is requested. Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs) ' Fires at the beginning of each request End Sub Quote wayne The Road Goes on Forever and the Party Never Ends - Robert Earl Keen
utilitaire Posted August 2, 2005 Author Posted August 2, 2005 I'm going to suggest global.asax, but not the Session sub. Can you do it as part of the Begin Request? This fires each and everytime a page from the application is requested. Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs) ' Fires at the beginning of each request End Sub thank you so much! I didn't event know this method was fired each time a page is requested!! Simple and perfect! Thank you again! :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.