Copied to clipboard

Flag this post as spam?

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


  • Ananth 2 posts 72 karma points
    Dec 04, 2019 @ 15:06
    Ananth
    0

    Unable to retrieve the children from current page

    hi, I am using umbraco 7, There will be two pages I created one is home and another is login. I added the login as child under the home page.

    When comes to dot net I created one controller and in that I am retrieving the login by using like this Page=CurrentPage.Children.FirstOrDefault(c => c.DocumentTypeAlias == "login"); I am getting Null value reference

    Please anyone help me to solve this problem

    Thanks,

  • Mario Lopez 168 posts 958 karma points MVP 4x c-trib
    Dec 05, 2019 @ 20:41
    Mario Lopez
    1

    I think it would help if we can see the whole controller.

  • Ananth 2 posts 72 karma points
    Dec 06, 2019 @ 07:31
    Ananth
    0

    public virtual ActionResult RegisterForm() {

            using (var db = new UserDataDbContext("UserData"))
            {
          var Page = CurrentPage.Children.FirstOrDefault(c => c.DocumentTypeAlias == "ConfirmationPage");
                    return RedirectToUmbracoPage(Page , "id=" + event.Id);
    
             }
          return CurrentUmbracoPage();
        }
    

    This is my controller and here I am not getting children page. In this Current page is working and So I created the child page. It is showing the count=0.

  • Mario Lopez 168 posts 958 karma points MVP 4x c-trib
    Dec 15, 2019 @ 22:35
    Mario Lopez
    0

    Why are you using a UserDataDbContext? It's not being used anywhere in your code.

    Is your method inheritinh from RenderMvcController, you can't just use a normal MvcController with Umbraco.

    If you are new to Umbraco I recommend you to start putting your code in your view and not in a controller, it makes things easier.

  • 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