Question

I'm trying to use the MvcSiteMapProvider, but to create my own custom layout. I used nuget to install MvcSiteMapProvider version 3.2.3.0 to my project and created this file for development. However, when I try to loop through the root node's children, there aren't any.

<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-3.0"
            xsi:schemaLocation="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-3.0 MvcSiteMapSchema.xsd"
            enableLocalization="true">
  <mvcSiteMapNode title="Home" controller="Home" action="Index">
    <mvcSiteMapNode title="Reports" controller="Reports" action="Index"/>
    <mvcSiteMapNode title="Queries" controller="Queries" action="Index"/>
    <mvcSiteMapNode title="Tools" controller="Tools" action="Index">
      <mvcSiteMapNode title="Markets" controller="Markets" action="Index">
        <mvcSiteMapNode title="Boundary Files" controller="Markets" action="BoundaryFiles" />
        <mvcSiteMapNode title="Mass Update" controller="Markets" action="MassUpdate" />
        <mvcSiteMapNode title="SHOULD NOT BE HERE" controller="Home" action="Headings" />
      </mvcSiteMapNode>
      <mvcSiteMapNode title="Categories" controller="Categories" action="Index"/>
      <mvcSiteMapNode title="Blasts" controller="Blasts" action="Index">
        <mvcSiteMapNode title="Get Blast" controller="Blasts" action="Get" />
      </mvcSiteMapNode>
      <mvcSiteMapNode title="Alerts" controller="Alerts" action="Index"/>
      <mvcSiteMapNode title="Applications" controller="Applications" action="Index"/>
    </mvcSiteMapNode>
    <mvcSiteMapNode title="Subscribers" controller="Subscribers" action="Index" />
  </mvcSiteMapNode>
</mvcSiteMap>

The root node doesn't appear to have any children however:

enter image description here

I can't figure out what's wrong. I've replaced the root with the very action getting executed and gave it a similar child, but that didn't work:

<mvcSiteMapNode title="ASDFG" controller="Test" action="TestSiteMap">
  <mvcSiteMapNode title="ASDFGHJKL" controller="Test" action="TestSiteMap"/>
Was it helpful?

Solution

It is hard to say what was happening here. If I had to guess, I would say that it might have had something to do with the fact that the child nodes were being added directly to the node in v3, in which case the sitemap could not track them. This option has been removed in MvcSiteMapProvider v4 to ensure that all of the nodes are added directly to the sitemap and tracked by its internal collections.

I would suggest upgrading to see if this behavior is reproducible in v4.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top