Copied to clipboard

Flag this post as spam?

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


  • Nadia 45 posts 122 karma points
    Nov 16, 2016 @ 22:53
    Nadia
    0

    Custom Route - template file was found Error

    I am trying to implement a custom route, but getting a "No physical template file was found for template Index" error.

    If I remove the custom route, and just load the document it works fine. But as soon as I add in the custom route I get this error.

    When I debug at the controller, my model as a templateId and the template file does exist.

    RouteConfig:

     routes.MapUmbracoRoute(
               "EventDetails",
               "programme/event/{id}",
               new{ controller = "EventDetails",action = "Index"},
    
               new EventDetailsHandler()
           );
    

    Handler:

     public class EventDetailsHandler : UmbracoVirtualNodeRouteHandler
    {
        protected override IPublishedContent FindContent(RequestContext requestContext, UmbracoContext umbracoContext)
        {
            var helper = new UmbracoHelper(umbracoContext);
            string alias = typeof(EventDetails).Name;
            IPublishedContent content = helper.TypedContentAtRoot()
                .First()
                .Descendants()
                .First(d => d.DocumentTypeAlias.InvariantEquals(alias));
    
            return content;
        }
    }
    

    Controller (not actually doing anything, tried just not specifing the controller and get the same result):

     public override ActionResult Index(RenderModel model)
        {
    
            //Do some stuff here, then return the base method
            return base.Index(model);
    
        }
    
  • 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