Copied to clipboard

Flag this post as spam?

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

  • Tom 119 posts 447 karma points
    Nov 24, 2016 @ 13:01

    Using CurrentPage og Model on a page without a node

    Hi, I'm not sure I'm able to make this understandable, but here we go!

    I have created a custom route to a page called 'course'. The view uses the same layout as the rest of the website, but no matching document/node is created in Umbraco.

    So, when I go to I just want the page to use CurrentPage and Model as if it was on the home node. But I want to show my custom view of course.

    Now I'm just getting alot of nullpointers because of the missing CurrentPage and Model.

    Any smart way to do this?

  • Alex Skrypnyk 6134 posts 23953 karma points MVP 8x admin c-trib
    Nov 24, 2016 @ 14:13
    Alex Skrypnyk

    Hi Tom,

    You can use UmbracoHelper for getting Home page and use it like model for you view.

    Is it make sense for you?



  • Tom 119 posts 447 karma points
    Nov 25, 2016 @ 08:59

    I tried to make it work with an UmbracoVirtualNodeRouteHandler

                controller = "Course",
                action = "Index",
                Id = UrlParameter.Optional

    CourseVirtualNodeRouteHandler just returns my homepage node. But I still am missing the RenderModel, Any idea why?

  • Ali Kazai 11 posts 82 karma points c-trib
    Feb 20, 2020 @ 12:13
    Ali Kazai

    I know this was asked a long long time ago in a galaxy far far away lol but its better late than never to add a fix for future developers.

    I have come across the same problem and found that using this command has fixed it.

    IPublishedContent CurrentPage = Umbraco.AssignedContentItem;
Please Sign in or register to post replies

Write your reply to: