SiteMapProviderCollection.Add Method (SiteMapProvider)


Adds a SiteMapProvider object to the provider collection using the Name property as the key.

Namespace:   System.Web
Assembly:  System.Web (in System.Web.dll)

public void Add(
	SiteMapProvider provider


Type: System.Web.SiteMapProvider

The SiteMapProvider to add.

Exception Condition

provider is null.


The SiteMapProviderCollection is read-only.


A SiteMapProvider with the same name already exists in the SiteMapProviderCollection.

The SiteMapProviderCollection object that is returned by the Providers property is read-only. For this reason, you cannot use the Add and AddArray methods to programmatically add additional providers to the SiteMap at run time. Therefore, the Add and AddArray methods are used only in scenarios where you manually create site map provider objects and manage them with an instance of the SiteMapProviderCollection class. Use the Add method when you want to add a single SiteMapProvider to the SiteMapProviderCollection.

Because the SiteMap class is static, any SiteMapProvider contained in its Providers collection remains for the lifetime of the Web application.

.NET Framework
Available since 2.0
Return to top