SiteMapSection Class

Defines configuration settings that are used to support the infrastructure for configuring, storing, and rendering site navigation. This class cannot be inherited.

Namespace: System.Web.Configuration
Assembly: System.Web (in system.web.dll)

public sealed class SiteMapSection : ConfigurationSection
public final class SiteMapSection extends ConfigurationSection
public final class SiteMapSection extends ConfigurationSection
Not applicable.

The SiteMapSection class provides a way to programmatically access and modify the content of the configuration file siteMap section.

This example demonstrates how to specify values declaratively for several attributes of the siteMap section, which can also be accessed as members of the SiteMapSection class.

The following configuration file example shows how to specify values declaratively for the siteMap section.

  <siteMap defaultProvider="XmlSiteMapReader" enabled="true">
      <clear />
        type="XmlSiteMapProvider, System.Web, Version=1.1.3300.0,
              Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
        description="XmlSiteMapProvider that loads my.sitemap"/>

The following code example demonstrates how to use the SiteMapSection class.

#region Using directives

using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Web;
using System.Web.Configuration;


namespace Samples.Aspnet.SystemWebConfiguration
  class UsingSiteMapSection
    static void Main(string[] args)
        // Set the path of the config file.
        string configPath = "";

        // Get the Web application configuration object.
        Configuration config = WebConfigurationManager.OpenWebConfiguration(configPath);

        // Get the section related object.
        SiteMapSection configSection = 

        // Display title and info.
        Console.WriteLine("ASP.NET Configuration Info");

        // Display Config details.
        Console.WriteLine("File Path: {0}", 
        Console.WriteLine("Section Path: {0}",
        // Display Default Provider.
        Console.WriteLine("Default Provider: {0}",

        // Set Default Provider.
        configSection.DefaultProvider = 

        // Display Enabled value.
        Console.WriteLine("Enabled: {0}", configSection.Enabled);

        // Set Enabled value.
        configSection.Enabled = true;

        // Display the number of Providers
        Console.WriteLine("Providers Collection Count: {0}",

        // Display elements of the Providers collection property.
        foreach (ProviderSettings providerItem in configSection.Providers)
          Console.WriteLine("Provider Details:");
          Console.WriteLine("Name: {0}", providerItem.Name);
          Console.WriteLine("Type: {0}", providerItem.Type);

        // Update if not locked.
        if (!configSection.SectionInformation.IsLocked)
          Console.WriteLine("** Configuration updated.");
          Console.WriteLine("** Could not update, section is locked.");

      catch (Exception e)
        // Unknown error.

      // Display and wait

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0