0

PotalSiteMapProvider 不返回页面。我使用如下代码:

        PortalSiteMapProvider prov = PortalSiteMapProvider.CurrentNavSiteMapProviderNoEncode;
        prov.DynamicChildLimit = 0;
        prov.IncludeSubSites = PortalSiteMapProvider.IncludeOption.Always;
        prov.IncludePages = PortalSiteMapProvider.IncludeOption.Always;
        prov.IncludeHeadings = true;
        prov.IncludeAuthoredLinks = true;
        SiteMapNode root = prov.RootNode;

        //prov.IncludePages = PortalSiteMapProvider.IncludeOption.Always;
        SiteMapNodeCollection collection = prov.GetChildNodes(root);


        foreach (SiteMapNode thisNode in collection)
        {
            SiteMapNodeCollection thisCollection;
            if (thisNode.GetType() == typeof(PortalWebSiteMapNode))
            {
                prov.IncludePages = PortalSiteMapProvider.IncludeOption.Always;
                thisCollection = prov.GetChildNodes((PortalWebSiteMapNode)thisNode);
            }
        }

当我通过调试器查看时,thisCollection 从来没有任何子节点,尽管 thisNode 是一个有页面的子站点节点。我做错了什么,如何获取该节点中的页面?谢谢!

4

1 回答 1

0

这是我不久前在一个项目中使用的代码。它似乎为我正确地提取了子页面。

PortalSiteMapProvider portalProvider = (PortalSiteMapProvider)SiteMap.Providers["CurrentNavSiteMapProviderNoEncode"];
PortalSiteMapNode currentNode = portalProvider.CurrentNode as PortalSiteMapNode;
foreach (SiteMapNode childNode in currentNode.ChildNodes) {
   ...
}
于 2011-06-04T03:58:59.630 回答