Sep 17, 2009 at 6:04 PM
Edited Sep 17, 2009 at 6:06 PM

I'm continually getting an InvalidOperationException with the provider.  The message is "Multiple nodes with the same URL '/' were found. XmlSiteMapProvider requires that sitemap nodes have unique URLs."

My sitemap:

<siteMap enableLocalization="true" xmlns="">
  <mvcSiteMapNode title="Home" controller="Home" isDynamic="true" dynamicParameters="*">
    <mvcSiteMapNode title="Color Palette" controller="ColorPalette" />
    <mvcSiteMapNode title="UI Standards" controller="UIStandards">
      <mvcSiteMapNode title="Data Entry" controller="DataEntry">
        <mvcSiteMapNode title="Simple data entry" action="Simple" />
      <mvcSiteMapNode title="Reporting" controller="UIStandards" action="Reporting" />
      <mvcSiteMapNode title="Wizards" controller="UIStandards" action="Wizards" />
      <mvcSiteMapNode title="Tabs" controller="UIStandards" action="Tabs" />
    <mvcSiteMapNode title="Download" controller="Download" emphasized="True" />

My provider registration:

<add name="MvcSiteMapProvider"
    type="MvcSiteMap.Core.MvcSiteMapProvider, MvcSiteMap.Core"
    scanAssembliesForSiteMapNodes="false" />

I've wrestled with this for a while now.  Does anyone have any suggestions as to where to look for a resolution for this exception? 

Sep 17, 2009 at 6:56 PM
Edited Sep 17, 2009 at 7:03 PM

I've figured out that this happens when the "treatAttributesAsRouteValues" attribute is "false" because the node.Attributes() foreach loop in MvcSiteMapProvider.getMvcSiteMapNodeFromXMLElement(SiteMapNode, XElement) method ignores the "controller" and "action" attributes if "treatAttributesAsRouteValues" is "false".  Further down, if the !routeValues.ContainsKey("controller") conditional statement is satisfied, we try to find the controller from the current node's parent.

Instead, we should first look in the XElement attributes first, then query the parent node for its controller if the current XElement really is missing the "controller" attribute.  Also, if we really can't find a controller for a site map node, is it really fair to set the controller to "Home"?  I think if we can't find a contoller, we should really throw an exception.  Of course, this means that implicitly, we actually do require a "controller" attribute to be set somewhere in the site map configuration (perhaps at least on the root node).

What do you guys think about this?

Sep 17, 2009 at 8:47 PM

I agree. The defaulting to Home and Action of Index should be a provider configuration. You could probably get away with defaulting the action to Index, but some people may want to control that.



Sep 18, 2009 at 7:59 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.