App_Themes 在初始加载时未加载

发布于 2024-09-05 19:24:17 字数 922 浏览 1 评论 0原文

我有一个应用程序,不同的用户可以通过单个门户登录来登录。当他们登录时 中,如果他们属于超过 1 个公司,他们必须选择他们所属的公司。如果该公司有自定义主题,则主题将会更改。

我的应用程序的每个页面都继承一个“CustomPage”类

以下是自定义页面的代码:

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";
        }
    }
}

当客户属于超过 1 个公司,并且他们选择自己所属的公司时,主题加载得很好。

所以,我遇到的问题是:

如果它们只属于 1 个公司,则会自动选择该公司,但主题不会立即加载。但是,如果我刷新页面,主题加载得很好。即使默认主题也不会加载。在我刷新之前,该页面根本没有 CSS。

我什至查看源代码并查找我的 css 名称,但它们不在那里。我刷新并做了同样的事情,它们就在那里。

我没有使用表单身份验证,并且 Web 配置中的默认主题是“默认”,您

<pages theme="Default">

对可能发生的情况有什么想法吗?如果您需要澄清任何事情,请询问。

谢谢!

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 even view source and look for my css names and they are not there. 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"

<pages theme="Default">

Any thoughts to what might be going on? If you need clarification on anything, please ask.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌化 2024-09-12 19:24:17

我发现了问题。在登录期间设置公司信息之前调用 Page_PreInit。

因此,在用户登录后,我就在此处调用逻辑来检查公司详细信息与母版页加载中的情况。

I found the problem. The Page_PreInit was being called before the Company information was being set during login.

So after the user logged in, that is where I called the logic to check the company details versus in the master page load.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文