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.