From 15692d0aa688959a7280ed85d32dbe08a8972caf Mon Sep 17 00:00:00 2001 From: Shad Storhaug Date: Sun, 18 Aug 2013 07:14:32 +0700 Subject: [PATCH] Fixed incorrect logic in SiteMapPathHelper. --- .../Web/Html/SiteMapPathHelper.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/MvcSiteMapProvider/MvcSiteMapProvider/Web/Html/SiteMapPathHelper.cs b/src/MvcSiteMapProvider/MvcSiteMapProvider/Web/Html/SiteMapPathHelper.cs index 5671cfe5..60ebd4b0 100644 --- a/src/MvcSiteMapProvider/MvcSiteMapProvider/Web/Html/SiteMapPathHelper.cs +++ b/src/MvcSiteMapProvider/MvcSiteMapProvider/Web/Html/SiteMapPathHelper.cs @@ -189,13 +189,20 @@ private static SiteMapPathHelperModel BuildModel(MvcSiteMapHtmlHelper helper, So // Build model var model = new SiteMapPathHelperModel(); var node = startingNode; - // Check visibility and ACL - if (node != null && node.IsVisible(sourceMetadata) && node.IsAccessibleToUser()) + while (node != null) { - // Add node - model.Nodes.AddRange((new SiteMapNodeModel(node, sourceMetadata)).Ancestors); + bool nodeVisible = node.IsVisible(sourceMetadata); + if (nodeVisible && node.IsAccessibleToUser()) + { + var nodeToAdd = new SiteMapNodeModel(node, sourceMetadata); + model.Nodes.Add(nodeToAdd); + } + node = node.ParentNode; } + model.Nodes.Reverse(); + return model; + } ///