[英]App_Themes Not Loading on Initial Load
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 我的应用程序拥有的每个页面都继承了一个“ CustomPage”类
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. 如果它们仅属于1家公司,则会自动选择公司,但不会立即加载主题。 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.
在刷新之前,该页面根本没有CSS。
I even view source and look for my css names and they are not there. 我什至查看源代码并查找我的CSS名称,但它们不存在。 I refresh and do the same thing, and they are there.
我刷新并做同样的事情,它们在那里。
I am not using forms authentication and the default theme in the web config is "Default" 我未使用表单身份验证,Web配置中的默认主题为“默认”
<pages theme="Default">
Any thoughts to what might be going on? 有什么想法吗? If you need clarification on anything, please ask.
如果您需要任何澄清,请询问。
Thanks! 谢谢!
I found the problem. 我发现了问题。 The Page_PreInit was being called before the Company information was being set during login.
在登录期间设置公司信息之前,已调用Page_PreInit。
So after the user logged in, that is where I called the logic to check the company details versus in the master page load. 因此,在用户登录后,这就是我调用逻辑以检查公司详细信息和母版页加载中的逻辑的地方。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.