Template controller

What is it ?

A template controller is a controller which allows to display modules and use their properties. Its routing is defined by the MVC controller, it can be called by using the default MVC route /mycontroller/myaction.

Make a template controller

If you want to use the default template controller, your controller must derive from TemplateController which is available in the Kastra.Core.Controllers namespace.

An example of a template controller could be :

MyController.cs


using Kastra.Core;
using Kastra.Core.Controllers;
using Kastra.Core.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ViewComponents;

namespace Kastra.Web.Controllers
{
    public class MyController : TemplateController
    {
        public MyController(IViewManager viewManager,
                              CacheEngine cacheEngine, 
                              IViewComponentDescriptorCollectionProvider viewcomponents, 
                              IParameterManager parameterManager) 
                            : base(viewManager, cacheEngine, viewcomponents, parameterManager){}
    }
}