Export (0) Print
Expand All

SiteMapProviderCollection.Add Method (ProviderBase)

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

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

public override void Add(
	ProviderBase provider
)

ExceptionCondition
ArgumentNullException

The Name of the SiteMapProvider is null.

ArgumentException

provider is not an instance of the SiteMapProvider class.

- or -

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

NotSupportedException

The SiteMapProviderCollection is read-only.

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 add additional providers programmatically 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. The Add(ProviderBase) method checks the type of the specified provider, and then calls the Add(SiteMapProvider) method to add it to the collection.

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

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft