In a project I'm working on, I've taken a bunch of code that was running in the main Master Page and moved it up to Session_Start in Global.asax.cs. So far, so good!
However, to utilize this code, the following still needs to be added to every single ASPX file in my project:
private string _modularLevelVariable1;
protected void Page_PreInit(object sender, EventArgs e)
{
_modularLevelVariable1 = ... (value retrieved from ConfigurationManager.AppSettings["AppKey1"];
Page.MasterPageFile = ConfigurationManager.AppSettings["AppKey2"];
}
To streamline this even further, I realized that I could create a BasePage.cs and do this:
public class BasePage : System.Web.UI.Page{ public string _modularLevelVariable1 = ... (value retrieved from ConfigurationManager.AppSettings["AppKey1"];}public class Default : BasePage
{
protected void Page ...
Go to the complete details ...