SiteMapProvider.CurrentNode 属性    
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取表示当前请求页的 SiteMapNode 对象。
public:
 virtual property System::Web::SiteMapNode ^ CurrentNode { System::Web::SiteMapNode ^ get(); };public virtual System.Web.SiteMapNode CurrentNode { get; }member this.CurrentNode : System.Web.SiteMapNodePublic Overridable ReadOnly Property CurrentNode As SiteMapNode属性值
表示当前请求页的 SiteMapNode;否则,如果没有找到或不能为当前用户返回 SiteMapNode,则为 null。
示例
下面的代码示例演示如何在实现 CurrentNode 抽象 SiteMapProvider 类的类中实现 属性。
此代码示例是为 SiteMapProvider 类提供的一个更大示例的一部分。
// Implement the CurrentNode property.
public override SiteMapNode CurrentNode
{
  get
  {
    string currentUrl = FindCurrentUrl();
    // Find the SiteMapNode that represents the current page.
    SiteMapNode currentNode = FindSiteMapNode(currentUrl);
    return currentNode;
  }
}
// Implement the RootNode property.
public override SiteMapNode RootNode
{
  get
  {
    return rootNode;
  }
}
' Implement the CurrentNode property.
Public Overrides ReadOnly Property CurrentNode() As SiteMapNode
  Get
    Dim currentUrl As String = FindCurrentUrl()
    ' Find the SiteMapNode that represents the current page.
    Dim aCurrentNode As SiteMapNode = FindSiteMapNode(currentUrl)
    Return aCurrentNode
  End Get
End Property
' Implement the RootNode property.
Public Overrides ReadOnly Property RootNode() As SiteMapNode
  Get
    Return aRootNode
  End Get
End Property
注解
在 SiteMapResolve 尝试检索 SiteMapNode 对象之前引发 事件,使事件订阅服务器能够返回 类的 SiteMapNode 实例。 如果没有事件订阅服务器,则 SiteMapProvider 类使用当前 HTTP 上下文调用 FindSiteMapNode 方法,以检索 SiteMapNode 表示当前请求的页面的 。
如果当前请求的页面与 不对应,SiteMapNodenull则返回 。 如果启用了安全修整,并且不允许用户访问 ,SiteMapNodenull则返回 。