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.
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.
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
Then in application starting event i have
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
Hmm it should work. You can check the Hybrid Framework where I'm doing the same thing
ApplicationStarting: https://github.com/jbreuer/Hybrid-Framework-for-Umbraco-v7-Best-Practises/blob/master/Umbraco.Extensions/Events/UmbracoEvents.cs#L59
DefaultController: https://github.com/jbreuer/Hybrid-Framework-for-Umbraco-v7-Best-Practises/blob/master/Umbraco.Extensions/Controllers/DefaultController.cs
Jeroen
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
is working on a reply...