I have a master page with the following code:
protected void Page_Init(object sender, EventArgs e)
{
if (Session["SessionUserPreferences"] == null)
{
MyHelper.LoadInitialUserData(6);
}
}
In my code behind, I use some of the data that’s loaded in SessionUserPreferences to display the page in the Page_Load event. The Page_Init event of the master page comes before the Page_load event of the aspx page so in theory the data should be in the session when I reach the code behind. But is that always going to be the case? Can the time needed to load the data from the DB be greater than the time the Page_load event will trigger? I’m using InProc Session.
Thanks.
Page_Load wont execute until Page_Init finishes. You should still check if it is null in Page_Load though.