Multiple nodes with the same key '' were found. XmlSiteMapProvider requires that sitemap nodes have unique keys.

Sep 22, 2009 at 6:15 AM

In the regular sitemaps, you were allowed to have entries that did not have a URL at all.  I guess those were 'ignored' when looking checking for nodes with the same key.

For example, you could have this.

<siteMapNode url="~/default.aspx" title="Test"  >
            <siteMapNode url="~/Page1.aspx" title="Page 1"  />
            <siteMapNode url="~/Page1.aspx" title="Page 2"  />
            <siteMapNode title="Reports"  description="Reports" >
                  <siteMapNode url="~/Page3.aspx" title="Page 3"  />
                  <siteMapNode url="~/Page4.aspx" title="Page 4"  />
            <siteMapNode title="Actions">
                  <siteMapNode url="~/Page5.aspx" title="Page 3"  />
                  <siteMapNode url="~/Page6.aspx" title="Page 4"  />

When this would be rendered in a menu, the 'Reports' and 'Actions' would be the main sub menu, but of course you could not click on it.

Along these same lines, if you have multiple <siteMapNode> items that do not provide a title (like when they are there for the sitemap, but not would not be used in a menu), the same error above is given - even though the URL's are unique.  Along these same lines, if you provide a title that is the same for 2 sitemapnodes, you get an error about that.    This occurs if you use my new mvcSiteMapNode that supports the url attribute directly also.

Please advise.

Sep 22, 2009 at 6:34 AM

Looks like again, all the above problems are easily solved by a simple change.

MvcSiteMapProvider.cs, GetMvcSiteMapNodeFromXMLElement

Change the Generate key for node code to this:

            var key = GetAttributeValue(node.Attribute("key")) ??
                      (GetAttributeValue(node.Attribute("area")) ?? (GetAttributeValue(node.Attribute("url")) ?? "")) + "_" + (GetAttributeValue(node.Attribute("controller")) ?? "") + "_" + (GetAttributeValue(node.Attribute("action")) ?? "") + "_" + (GetAttributeValue(node.Attribute("title")) ?? "");

That takes care of all the above issues, except in the case where you have a sitemap item that does not have a url at all.  Problem is if no url, then it uses defaults of mvcSiteMapNode - so you have to provide a url on those or use a regular siteMapNode on those.

Again, if you can make this change, would be great.

Sep 23, 2009 at 5:57 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Jun 4, 2014 at 7:29 AM
Edited Jun 4, 2014 at 7:30 AM
I have my sitemap as:
<?xml version="1.0" encoding="utf-8" ?>


<siteMapNode title="Home" controller="Home" action="Index" key="1" id="21">
<siteMapNode title="Accounts" key="100" >

  <siteMapNode title="Periodic Processings" key="110" >
    <siteMapNode title="1009 Electric Filing" key="111" data-level="3" url="" />
    <siteMapNode title="T5018 (CRPS) Electronic Filing" key="112" data-level="3" url=""/>

  <siteMapNode title="Setup" key="120">
    <siteMapNode title="Recurring Vendors" key="121" />

  <siteMapNode title="Transactions" key="130">
    <siteMapNode title="Adjustment Batch List" key="131" />

  <siteMapNode title="Vendors" key="140">
    <siteMapNode title="Recurring Vendors" key="141"/>

  <siteMapNode title="Customer" key="150">
    <siteMapNode title="Recurring Vendors" key="151" />

  <siteMapNode title="Transactions" key="160">
    <siteMapNode title="Recurring Vendors" key="161"/>




and i have implement the ""

and create an Instance of
MvcSitemapProvider provider = new MvcSitemapProvider();

to applend a view

getting error as Multiple nodes with the same key '' were found. XmlSiteMapProvider requires that sitemap nodes have unique keys.

and i update my MvcSiteMapProvider.cs, GetMvcSiteMapNodeFromXMLElement
but still get the same error.

so I need some advice.

Thanks You.