Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

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

wayne

 

The Road Goes on Forever and the Party Never Ends - Robert Earl Keen

Posted
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! :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...