0

I have installed Sensenet Services and Sensenet ECM Webpages packages in my .Net project using Nuget packages and followed the installation steps mentioned in the readme file.

My Global.asax' markup looks like

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

and my Global.asax.cs file looks like

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


        }
    }
}

In debug mode the application starts and initializes all components. But when it gets to the implicit code for starting the application " base.Application_Start(sender, e, application);" the debugger doesn't returns back or no exception is throwing simply the application runs without an output infinitely. Could you please help me what is the issue with my code.

Aniko Litvanyi
  • 2,109
  • 1
  • 21
  • 25

1 Answers1

0

I think the code in your example is more complicated than it should be. You do not have to have your own class that inherits from HttpApplication, sensenet already has one. You only have to inherit your MvcApplication class from the base class above (SenseNet.Portal.SenseNetGlobal) and call the original generated methods after the base app start method call.

See an example here:

This repository contains a few pre-built project templates that include one or more sensenet components (NuGet packages) already installed, we plan to keep these up-to-date.

I'll add the example class here, it is really short:

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);
        }
    }
}
Miklós Tóth
  • 1,490
  • 13
  • 19
  • Yes this is the code I Tried initially but to make sure which of this code has the issue I created a main class. And Even after the above mentioned code my application is not getting started it went out and not returns any expectation at the line " base.Application_Start(sender,e,application) ". I don't know what's the issue in starting the application with same code you mentioned in the comment and in the github. – Ashik M Hussain Apr 16 '18 at 05:34