Copied to clipboard

Flag this post as spam?

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


  • Cristhian Amaya 52 posts 423 karma points
    Apr 19, 2014 @ 10:29
    Cristhian Amaya
    0

    route hijacking and child document type

    Hi,

    I'm using route hijacking in an Umbraco 7.1.1 project and I have a weird issue. I have a document type called Textpage and this document type is allowed to have child nodetypes of the same document type, i.e, Textpage. Also, the template of the document type is called Textpage.

    In the backoffice I have something like this:

    • Textpage
      • Child textpage 1
      • Child textpage 2
      • Child textpage 3

    My controller is very simple:

    public class TextpageController : RenderMvcController
    {
        private readonly ICommonService commonService;
        private readonly ITextpageService textpageService;
    
        public TextpageController(ICommonService commonService,
            ITextpageService textpageService)
        {
            this.commonService = commonService;
            this.textpageService = textpageService;
        }
    
        public ActionResult Textpage()
        {
            var model = textpageService.GeTextpage(commonService.PageId);
            return View(model);
        }
    }
    

    As you can see I'm using template routing as described here: http://our.umbraco.org/documentation/Reference/Mvc/custom-controllers#Routingviatemplate

    This works perfectly for Textpage but it doesn't work at all for any Child textpage and I don't know why, considering that the document type and the template are the same.

    I'm not getting any error, in fact the http response is 200 but I see a blank page and my custom controller doesn't execute.

    I'd appreciate any ideas you have to solve this issue.

    Thanks. Cristhian.

  • Cristhian Amaya 52 posts 423 karma points
    Apr 19, 2014 @ 23:03
    Cristhian Amaya
    100

    Solved!!

    I had this route:

    routes.MapRoute(
        name: "defaultMvcRoute",
        url: "{controller}/{action}",
    );
    

    I changed that for this:

    routes.MapRoute(
        name: "MyProject_DefaultRoute",
        url: "MyProject/{controller}/{action}",
        namespaces: new[] { "MyProject.Core.Controllers" }
    );
    

    And now everything is working like a charm.

    Cheers,

    Cristhian.

Please Sign in or register to post replies

Write your reply to:

Draft