using System.Web.Mvc; namespace Umbraco.Web.Mvc { /// /// Ensures that if an action for the Template name is not explicitly defined by a user, that the 'Index' action will execute /// public class RenderActionInvoker : ControllerActionInvoker { /// /// Ensures that if an action for the Template name is not explicitly defined by a user, that the 'Index' action will execute /// /// /// /// /// protected override ActionDescriptor FindAction(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, string actionName) { var ad = base.FindAction(controllerContext, controllerDescriptor, actionName); //now we need to check if it exists, if not we need to return the Index by default if (ad == null) { //check if the controller is an instance of RenderMvcController if (controllerContext.Controller is RenderMvcController) { return new ReflectedActionDescriptor(controllerContext.Controller.GetType().GetMethod("Index"), "Index", controllerDescriptor); } } return ad; } } }