App_Themes Not Loading on Initial Load
- by Jason Heine
Hello,
I have an application where different users can log in via a single portal login. When they log 
in, if they belong to more than 1 company they have to select the company they belong to. The theme will change if there is a custom theme for that company.
Each page my application has inherits a "CustomPage" class
Here is the code for the custom page:
public class CustomPage : Page
{
    protected void Page_PreInit(object sender, EventArgs e)
    {
        if (Globals.Company != null && Directory.Exists(Page.MapPath("~/App_Themes/" + Globals.Company.CompanyName)))
        {
            Page.Theme = Globals.Company.CompanyName;
        }
        else
        {
            Page.Theme = "Default";
        }
    }
}
When the customer belongs to more than 1 company, and they select the company they belong to, the theme loads just fine. 
So, the problem I am having is this:
If they belong to just 1 company, the company is automatically selected but the theme does not load right away. However, if I refresh the page, the theme loads just fine. Even the default theme will not load. The page has no css at all until I refresh. 
I am not using forms authentication and the default theme in the web config is "Default"
<pages theme="Default">
Any thoughts to what might be going on? If you need clarification on anything, please ask.
Thanks!