Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ismail Mayat 4511 posts 10059 karma points MVP 2x admin c-trib
    Feb 05, 2016 @ 14:42
    Ismail Mayat
    0

    Default custom controller not running

    I am trying to create effectively a global hijack so that if fires for every doc type / page. I have created a Controller looks like

     public class DefaultCustomController : RenderMvcController
    {
        public override ActionResult Index(RenderModel model)
        {
            //todo cache
            var searchSettings = ServiceFactory.GetGlobalConfig(this.CurrentPage.Id).SiteSearchSettings;
    
            ViewBag.SearchSettings = searchSettings;
    
            //Do some stuff here, then return the base method
            return View(model);
        }
    }
    

    Then in application starting event i have

    public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            DefaultRenderMvcControllerResolver.Current.SetDefaultControllerType(typeof(DefaultCustomController));
        }
    

    When i put breakpoints on i can see the onapplicationstarting event firing and wiring everything up. When i hit a page the code in my controller does not fire.

    Am i missing something?

    Regards

    Ismail

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Feb 05, 2016 @ 14:46
  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Feb 05, 2016 @ 14:47
    Jeroen Breuer
    0

    The DefaultController is only hit if you don't have another controller that matches the name of the documenttype. Otherwise it will hit that controller.

    Jeroen

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies