1
votes

I am using MvcSiteMapNode without xml just with the decorator's way. As i said in this post

I am sure that i have only one node with empty root node. Also it always works, except some times that i get this error.

There is more than one node declared without a parent key. The parent key must be set for all but 1 node in the SiteMap. The node with no parent key will be considered the root node. Note that when defining nodes in XML, the XML file must contain the root node.

You can disable XML configuration by setting the MvcSiteMapProvider_EnableSiteMapFile setting to "false". For an external DI configuration, you can disable XML parsing by removing the XmlSiteMapNodeProvider from the MvcSiteMapProvider DI module.

Alternatively, you can set the MvcSiteMapProvider_IncludeRootNodeFromSiteMapFile setting to "false" to exclude the root node from the XML file, but include all of the other nodes. For an external DI configuration, this setting can be found on the constructor of the XmlSiteMapNodeProvider.

SiteMapCacheKey: 'sitemap://localhost/'

Ambiguous Root Nodes:

ParentKey: '' | Controller: 'Home' | Action: 'Index' | Area: 'Admin' | URL: '/Admin' | Key: 'root' | Source: 'MvcSiteMapNodeAttribute'

ParentKey: '' | Controller: 'Home' | Action: 'Index' | Area: 'Admin' | URL: '/Admin' | Key: 'root' | Source: 'MvcSiteMapNodeAttribute'

my App.Settings

<add key="MvcSiteMapProvider_EnableSiteMapFile" value="false" />
<add key="MvcSiteMapProvider_IncludeRootNodeFromSiteMapFile" value="false" />
<add key="MvcSiteMapProvider_IncludeAssembliesForScan" value="dllmain,dll2" />
<add key="MvcSiteMapProvider_UseExternalDIContainer" value="false" />
<add key="MvcSiteMapProvider_ScanAssembliesForSiteMapNodes" value="true" />

I think it has to do, with the way sitemap is it initialized. It might be vulnerable to cross-thread operation. It might get double initialized.

Do you have any advice for this?

Thanks in advance.

1
That just a guess. I will try to find more details.xrklvs
Could you post your MvcSiteMapNode for the home page of the site as well as for the root of the Admin area (if they are different)?NightOwl888
Lets redefine some things. Also i made some new observations. I have 2 areas. One Admin and one Public. I use mvcsitemapProvider only in the admin. Public site is very simple for some input. So the controllers in Public area are empty of nodes. (Also i don't define every method of my controllers as a node.) now. When i start the iisexpress and my first get is in a url of the Admin website everything works fine. When my first get is in the public website then i get this error.xrklvs
Admin HomeController index method (the only one with ParentKey null)--------------------------------------------->[MvcSiteMapNode(Title = "title", Description = "desc", Key = "root", ParentKey = null, ImageUrl = "fa-home", Order = 0)] public ActionResult Index()xrklvs

1 Answers

0
votes

Please have a look at this answer for help with setting up MvcSiteMapProvider with areas. The routes have to be configured using the correct conventions or it won't work right.

If you are certain that you only have 1 node in your entire site that has not set the parent node (or has set it to null or empty string) AND you are using [MvcSiteMapNode] attributes, this could be caused by the assemblies being loaded into the AppDomain more than one time. Check the AppDomain.CurrentDomain.GetAssemblies() method to see if your target assemblies (in this case dllmain and dll2) are in the result more than once.