Nodes are skipped for some reason when creating a menu

Sep 21, 2011 at 2:29 PM

Hello,

 

I am using this code ...

@Html.RenderSideNavigation(Html.MvcSiteMap().Menu(Html.MvcSiteMap().Provider.CurrentNode, truefalse, 1, true)

to create side-bar navigation elements.

 

I have isolated the fact that...

Html.MvcSiteMap().Provider.CurrentNode

... does, in fact, only have three child nodes before my html helper is called.

However, the xml in the site map is defined as such (I added comments to highlight the missing nodes) ...

<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-3.0" enableLocalization="true">
    <mvcSiteMapNode title="Home" controller="Home" action="Index" Id="" changeFrequency="Always" updatePriority="Normal">
        <mvcSiteMapNode title="Products" controller="Products" action="Index" Id="" changeFrequency="Always" updatePriority="Normal">
            <mvcSiteMapNode title="Metal Detectors - Industrial" controller="Products" action="Index" Id="Metaldetectorsindustrial" changeFrequency="Always" updatePriority="Normal">
                <mvcSiteMapNode title="Standard Metal Detector Conveyor Systems" controller="Products" action="Index" Id="Mdconvstd" changeFrequency="Always" updatePriority="Normal" />
                <!--Skipped-->
                <mvcSiteMapNode title="E-Z Tec Metal Detectors" controller="Products" action="Index" Id="Eztecmetaldetectors" changeFrequency="Always" updatePriority="Normal">
                    <mvcSiteMapNode title="E-Z Tec  DSP Metal Detectors" controller="Products" action="Index" Id="Eztecdspaperture" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="Metal Detector Conveyor Systems" controller="Products" action="Index" Id="MDCS" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="E-Z Tec  Pharmaceutical Metal Detectors" controller="Products" action="Index" Id="Md205p" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="E-Z Tec  Vertical Reject Metal Detector Systems" controller="Products" action="Index" Id="MD213" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="E-Z Tec  Liquid Line Metal Detectors" controller="Products" action="Index" Id="Md205lf" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="E-Z Tec Metal Detector / Checkweigher Systems" controller="Products" action="Index" Id="Checkweigher" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="E-Z Tec  SlimTec Aperture Metal Detectors" controller="Products" action="Index" Id="Md205sla" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="E-Z Tec Model VFS Metal Detectors" controller="Products" action="Index" Id="MD206" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="HandyTec  Hand-Held Metal Detector" controller="Products" action="Index" Id="Hhmd" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="E-Z Tec  SlimTec Single Surface Metal Detectors" controller="Products" action="Index" Id="Md205sls" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="E-Z Tec  Flat Bed Metal Detectors" controller="Products" action="Index" Id="MD205EZ111" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="E-Z Tec� 9000" controller="Products" action="Index" Id="PT111UK" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="E-Z Tec 9100 Metal Separators" controller="Products" action="Index" Id="PT112UK" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="PolyMag - Metal and X-Ray Detectable Plastic Additives " controller="Products" action="Index" Id="Polymagmasterbatchadditives" changeFrequency="Always" updatePriority="Normal" />
                </mvcSiteMapNode>
                <mvcSiteMapNode title="Metalarm Metal Detectors" controller="Products" action="Index" Id="Metalarmmetaldetector" changeFrequency="Always" updatePriority="Normal">
                    <mvcSiteMapNode title="Metalarm MA3600 Metal Detector" controller="Products" action="Index" Id="MA3600" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="Model TR Metalarm Metal Detector" controller="Products" action="Index" Id="Metalrm" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="Model TR-10 Metalarm Metal Detectors" controller="Products" action="Index" Id="Modeltr10md" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="Model BR Metalarm Metal Detector" controller="Products" action="Index" Id="Metbr" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="Model PL Metalarm Metal Detector" controller="Products" action="Index" Id="Metpl" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="Model PL2 Metalarm Metal Detector" controller="Products" action="Index" Id="Metpl2" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="Model VC Metalarm Metal Detector" controller="Products" action="Index" Id="Metvc" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="Model 7000 SS Metalarm Metal Detector" controller="Products" action="Index" Id="Metss" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="HandyTec  Hand-Held Metal Detector" controller="Products" action="Index" Id="Hhmd" changeFrequency="Always" updatePriority="Normal" />
                </mvcSiteMapNode>
                <mvcSiteMapNode title="1200 Series Metal Detectors" controller="Products" action="Index" Id="1200Seriesmetaldetector" changeFrequency="Always" updatePriority="Normal">
                    <mvcSiteMapNode title="Model 1210 Metal Detector" controller="Products" action="Index" Id="MD1210" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="Megatec Model 1220 Metal Detectors" controller="Products" action="Index" Id="Megatec" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="Model 1230 Metal Detector" controller="Products" action="Index" Id="MD1230" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="Model 1235 Metal Detector" controller="Products" action="Index" Id="MD1235" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="Model 1241 Metal Detector" controller="Products" action="Index" Id="MD1241" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="Model 1250 Metal Detector" controller="Products" action="Index" Id="MD1250" changeFrequency="Always" updatePriority="Normal" />
                    <mvcSiteMapNode title="Model 1260 Metal Detector" controller="Products" action="Index" Id="MD1260" changeFrequency="Always" updatePriority="Normal" />
                </mvcSiteMapNode>
                <!--Skipped-->
                <mvcSiteMapNode title="PolyMag - Metal and X-Ray Detectable Plastic Additives " controller="Products" action="Index" Id="Polymagmasterbatchadditives" changeFrequency="Always" updatePriority="Normal" />
                <!--Skipped-->
                <mvcSiteMapNode title="Reprints" controller="Products" action="Index" Id="Reprints" changeFrequency="Always" updatePriority="Normal" />
            </mvcSiteMapNode>
        </mvcSiteMapNode>
    </mvcSiteMapNode>
</mvcSiteMap>

Any input on why my xml isn't getting parsed properly would be greatly appreciated.

 

 

 

 

 

Sep 23, 2011 at 3:44 PM

I did a little bit more testing and I discovered that the symptom is related to data in other nodes.  When I use just the xml in my previous post it works normally.  When I include all of the children within the "products" node the indicated ones disappear.

Sep 23, 2011 at 3:47 PM

When I looked through my xml, I noticed that the skipped nodes are repeated ... but have different parents.

Jan 16, 2013 at 1:33 PM
Edited Jan 16, 2013 at 1:34 PM

Paul, did you ever get to the bottom of why your nodes were missing for certain and did you get a fix ?

Jan 17, 2013 at 1:54 AM

Hi notretro,

 

No, I never resolved the issue and wound up not using this in my project. 

What I believe was happening is that somewhere in the code it was detecting a "duplicate" when I inserted the "same" node at a different parent node.  And when the code detected the "duplicate" it either purposefully did nothing with it or an exception was thrown that never 'bubbled up' to where I could notice.

A time-crunch forced me to hack my own sitemap file reader or my site's navigation.