Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
TryGetCurrentNode property

PortalSiteMapProvider.TryGetCurrentNode property

SharePoint 2013

Gets a PortalSiteMapNode object that represents the item that a site user is currently visiting.

Namespace:  Microsoft.SharePoint.Publishing.Navigation
Assembly:  Microsoft.SharePoint.Publishing (in Microsoft.SharePoint.Publishing.dll)

public SiteMapNode TryGetCurrentNode { get; }

Property value

Type: System.Web.SiteMapNode
A PortalSiteMapNode object that represents the current item being visited, if one exists and the operation is inexpensive; otherwise, a null reference (Nothing in Visual Basic).

This property only gets the PortalSiteMapNode object if it would be an inexpensive operation.

For better performance, the CurrentNode property only avoids database queries by reading its data from a cache. However, if the object cannot be found in the cache, then a database query will still occur, which may be undesirable.

The TryGetCurrentNode property guarantees that these database queries cannot occur by instead returning a null reference (Nothing in Visual Basic) if the required objects were not already loaded into the cache. This is useful for nonessential operations that should only be performed if this can be done cheaply.

Show:
© 2015 Microsoft