Global.asax 未在预编译的 Sitefinity 项目上触发

发布于 2024-12-01 11:28:03 字数 2716 浏览 1 评论 0原文

我正在尝试启动 Sitefinity 4.2 项目。作为项目的一部分,我需要在 global.asax 文件中注册一些控件,如下所示:

    protected void Application_Start(object sender, EventArgs e) {

        //log call
        logStartUpCall(string.Concat("Application started at: ", DateTime.Now));

        Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);

        //log call
        logStartUpCall(string.Concat("Call made to bootstrapper: ", DateTime.Now));
    }

    protected void Application_OnStart(object sender, EventArgs e) {

        //log call
        logStartUpCall(string.Concat("Application started at: ", DateTime.Now));

        Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);

        //log call
        logStartUpCall(string.Concat("Call made to bootstrapper: ", DateTime.Now));
    }

    protected void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs args) {

        //log call
        logStartUpCall(string.Concat("Bootstrapper_Initialized:", " ", DateTime.Now));

        //register dialogs for custom module fields
        Telerik.Sitefinity.Web.UI.Dialogs.RegisterDialog<SitefinityModuleFields.Dialogs.SimpleImageSelectorDialog>();
        logStartUpCall(string.Concat("Simple Image Selector dialog registered at:", " ", DateTime.Now));
        Telerik.Sitefinity.Web.UI.Dialogs.RegisterDialog<SitefinityModuleFields.Dialogs.SimpleVideoSelectorDialog>();
        logStartUpCall(string.Concat("Simple Video Selector dialog registered at:", " ", DateTime.Now));
        Telerik.Sitefinity.Web.UI.Dialogs.RegisterDialog<ioscms.AppCode.ModuleFields.SimpleDocumentSelectorDialog>();
        logStartUpCall(string.Concat("Simple Document Selector dialog registered at:", " ", DateTime.Now));

        //log call
        logStartUpCall(string.Concat("Dialogs registered at: ", DateTime.Now));

    }

    protected void logStartUpCall(string message) {

        TextWriter tw = new StreamWriter(System.Web.Hosting.HostingEnvironment.MapPath("/App_Data/SiteFinity/Logs/Startup.log"), true);

        // write a line of text to the file
        tw.WriteLine(message);

        // close the stream
        tw.Close();

    }

这在正常调试模式下完美运行。我正在使用 Web 部署项目来部署该项目。这当然会预编译网站。我使用的设置是:

SingleAssembly 可更新:true DebugSymbols: false

sitefinity 的另一件事是应用程序无法预编译,因此必须删除 PrecompiledApp.config 文件。

我遇到的问题是 Application_Start (我也尝试过 Application_OnStart)从未执行,因此当然对话框从未注册。

我还尝试了“将每个单独的文件夹输出合并到其自己的程序集”选项,但无济于事。

有人有什么想法吗?

提前致谢 希格斯

I'm trying to launch a Sitefinity 4.2 project. As part of the project I need to register some controls within the global.asax file, like so:

    protected void Application_Start(object sender, EventArgs e) {

        //log call
        logStartUpCall(string.Concat("Application started at: ", DateTime.Now));

        Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);

        //log call
        logStartUpCall(string.Concat("Call made to bootstrapper: ", DateTime.Now));
    }

    protected void Application_OnStart(object sender, EventArgs e) {

        //log call
        logStartUpCall(string.Concat("Application started at: ", DateTime.Now));

        Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);

        //log call
        logStartUpCall(string.Concat("Call made to bootstrapper: ", DateTime.Now));
    }

    protected void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs args) {

        //log call
        logStartUpCall(string.Concat("Bootstrapper_Initialized:", " ", DateTime.Now));

        //register dialogs for custom module fields
        Telerik.Sitefinity.Web.UI.Dialogs.RegisterDialog<SitefinityModuleFields.Dialogs.SimpleImageSelectorDialog>();
        logStartUpCall(string.Concat("Simple Image Selector dialog registered at:", " ", DateTime.Now));
        Telerik.Sitefinity.Web.UI.Dialogs.RegisterDialog<SitefinityModuleFields.Dialogs.SimpleVideoSelectorDialog>();
        logStartUpCall(string.Concat("Simple Video Selector dialog registered at:", " ", DateTime.Now));
        Telerik.Sitefinity.Web.UI.Dialogs.RegisterDialog<ioscms.AppCode.ModuleFields.SimpleDocumentSelectorDialog>();
        logStartUpCall(string.Concat("Simple Document Selector dialog registered at:", " ", DateTime.Now));

        //log call
        logStartUpCall(string.Concat("Dialogs registered at: ", DateTime.Now));

    }

    protected void logStartUpCall(string message) {

        TextWriter tw = new StreamWriter(System.Web.Hosting.HostingEnvironment.MapPath("/App_Data/SiteFinity/Logs/Startup.log"), true);

        // write a line of text to the file
        tw.WriteLine(message);

        // close the stream
        tw.Close();

    }

This works perfectly in normal debug mode. I am using a Web Deployment Project to deploy the project. This of course precompiles the website. the settings I am using are:

SingleAssembly
UpdateAble: true
DebugSymbols: false

The other thing with sitefinity is that the app can't be precompiled, so the PrecompiledApp.config file has to be deleted.

The problem I'm experiencing is that the Application_Start (I've also tried Application_OnStart) is never executed, so of course the dialogs are never registered.

I've also tried the option "Merge each individual folder output to its own assembly" with no avail.

Does anyone have any ideas?

Thanks in advance
higgsy

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文