SPNavigation.GlobalNodes property

Gets the top-level navigation nodes for the current context.

Namespace:  Microsoft.SharePoint.Navigation
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public SPNavigationNodeCollection GlobalNodes { get; }

Property value

Type: Microsoft.SharePoint.Navigation.SPNavigationNodeCollection
A collection of top-level navigation nodes.

This property returns a collection that includes the following navigation nodes:

The following example is a console application that iterates over the collection of navigation nodes returned by the GlobalNodes property and prints the title, Id, and Url for each node.

using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Navigation;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("http://localhost"))
            {
                using (SPWeb web = site.OpenWeb("test"))
                {
                    string format = "{0, -30} {1, -5} {2}";
                    Console.WriteLine(format, "Title", "Id", "Url");

                    foreach (SPNavigationNode node in web.Navigation.GlobalNodes)
                    {
                        Console.WriteLine(format, node.Title, node.Id, node.Url);
                    }
                }
            }
            Console.Write("\nPress ENTER to continue....");
            Console.ReadLine();
        }
    }
}
Show: