This documentation is archived and is not being maintained.

SiteMap::RootNode Property

Gets a SiteMapNode object that represents the top-level page of the navigation structure for the site.

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

public:
static property SiteMapNode^ RootNode {
	SiteMapNode^ get ();
}

Property Value

Type: System.Web::SiteMapNode
A SiteMapNode that represents the top-level page of the site's navigation structure; otherwise, nullptr, if security trimming is enabled and the node cannot be returned to the current user.

ExceptionCondition
InvalidOperationException

The site map feature is not enabled.

- or -

The RootNode resolves to nullptr, which occurs if security trimming is enabled and the root node is not visible to the current user.

ConfigurationErrorsException

The default provider specified in the configuration does not exist.

HttpException

The feature is supported only when running in Low trust or higher.

The SiteMap class retrieves the RootNode property by requesting it from the provider. If there is a provider hierarchy, the SiteMap class retrieves the root node of the root provider in the hierarchy. To access the root node of the default provider, call the Provider property, which retrieves both the default provider and its RootNode property.

The XmlSiteMapProvider object, which is the default provider for the SiteMap class, supports only one RootNode.

If you implement your own SiteMapProvider class and override the abstract RootNode property, you must provide your own implementation to track the RootNode property of the SiteMapNode instance.

The root node must be visible to all users, by design. If the root node is not visible to all users when security trimming is enabled, accessing the RootNode property might result in an InvalidOperationException exception.

The following code example demonstrates how to use the RootNode property to retrieve the SiteMapNode object that represents the root node of the site, regardless of the current location in the page hierarchy.

No code example is currently available or this language may not be supported.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0
Show: