SiteMapProviderCollection.Add Method (ProviderBase)
Assembly: System.Web (in system.web.dll)
'Declaration Public Overrides Sub Add ( _ provider As ProviderBase _ ) 'Usage Dim instance As SiteMapProviderCollection Dim provider As ProviderBase instance.Add(provider)
public void Add ( ProviderBase provider )
public override function Add ( provider : ProviderBase )
Not applicable.
Parameters
- provider
The SiteMapProvider to add.
| Exception type | Condition |
|---|---|
| The Name of the SiteMapProvider is a null reference (Nothing in Visual Basic). | |
| provider is not an instance of the SiteMapProvider class. - or - A SiteMapProvider with the same name already exists in the SiteMapProviderCollection. | |
| 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.