When I try to iterate through the GlobalNodes collection using c# it is always empty unless I the site and manipulate the navigation settings manually.

Can anyone tell me why this is and/or give an alternative?

using (var site = new SPSite(url))
    using (var web = site.OpenWeb)
        // this is blank
        var nodes = web.Navigation.GlobalNodes[0].Children;
        //do things...

If I then go to the site/_layouts/settings.aspx > Look and Feel > navigation and move a site around a bit in the navigation settings the list then shows up when I refresh the page.

1 Answer 1


According to the API GlobalNodes contains "the top-level navigation nodes for the current context" which includes Home, QuickLaunch and TopNavigationBar. That suggests that the code you listed is empty because the 0th index (possibly Home) is empty.

What navigation nodes are you trying to access? Perhaps it would be better to use the Home QuickLaunch or TopNavigationBar members of web.Navigation directly?

  • TopNavigationBar is also empty until you make a change to the default navigation properties (changing the order is enough to fill the node collections)
    – Mauro
    Commented Aug 14, 2012 at 14:19
  • Looking at the API a bit more msdn.microsoft.com/en-us/library/gg277254.aspx "If UseShared returns false, the website has its own top link bar and you can add to it. If the property returns true, the website is using its parent site's top link bar." by modifying it I guess it sets useShared to false.
    – Mauro
    Commented Aug 14, 2012 at 14:22
  • Sorry, I think I misunderstood your question. The UseShared property and your guess sounds feasible though.
    – MattDuFeu
    Commented Aug 14, 2012 at 14:44
  • +1 though for helping me find a solution though.
    – Mauro
    Commented Aug 14, 2012 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.