0

我已经使用 Nuget 包在我的 .Net 项目中安装了 Sensenet Services 和 Sensenet ECM Webpages 包,并按照自述文件中提到的安装步骤进行操作。

我的 Global.asax 的标记看起来像

<%@ Application Codebehind="Global.asax.cs" Inherits="SenseNet.Portal.Global" Language="C#" %>

我的 Global.asax.cs 文件看起来像

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using System.Web.Optimization;
    using System.Web.Routing;

    namespace SensenetDemoApplication
    {
        public class MvcApplication : System.Web.HttpApplication
        {
            public void Application_Start()
            {
                AreaRegistration.RegisterAllAreas();
                FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
                RouteConfig.RegisterRoutes(RouteTable.Routes);
                BundleConfig.RegisterBundles(BundleTable.Bundles);
            }
        }
        public class Global : SenseNet.Portal.SenseNetGlobal
        {

        protected override void Application_Start(object sender, EventArgs e, HttpApplication application)
         {
             try
             {
                 MvcApplication original = new MvcApplication();
                 original.Application_Start();
                 base.Application_Start(sender, e, application);
             }
             catch (Exception )
             {

                 throw;
             }


        }
    }
}

在调试模式下,应用程序启动并初始化所有组件。但是当它到达用于启动应用程序的隐式代码“ base.Application_Start(sender, e, application); ”时,调试器不会返回或没有异常抛出,只是应用程序无限运行而没有输出。你能帮我看看我的代码有什么问题吗?

4

1 回答 1

0

我认为您示例中的代码比应有的复杂。您不必拥有自己的继承自HttpApplication的类,sensenet 已经拥有一个。您只需从上面的基类 ( SenseNet.Portal.SenseNetGlobal ) 继承您的 MvcApplication 类,并在基应用启动方法调用之后调用原始生成的方法。

在此处查看示例:

此存储库包含一些预构建的项目模板,其中包含一个或多个已安装的 sensenet 组件(NuGet 包),我们计划保持这些是最新的。

我将在这里添加示例类,它真的很短:

namespace SnWebApplication
{
    public class MvcApplication : SenseNet.Portal.SenseNetGlobal
    {
        protected override void Application_Start(object sender, EventArgs e, HttpApplication application)
        {
            base.Application_Start(sender, e, application);

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
    }
}
于 2018-04-15T19:13:22.297 回答