incorrect CurrentNode being returned

Feb 12, 2011 at 12:41 AM

MC2, MVCSitemap v2.3.1


I'm having an issue with the current node being returned as root when it should not be.



<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns="" >
<mvcSiteMapNode title="root">
<mvcSiteMapNode title="Home" description="" controller="Home" iconCls="homeIcon"/>
<mvcSiteMapNode title="About" description="" controller="About" action="Index" iconCls="aboutIcon"/>

I've tried this too


<mvcSiteMap xmlns="" >
<mvcSiteMapNode title="Home" controller="Home">
<mvcSiteMapNode title="Home" description="" controller="Home" action="index" iconCls="homeIcon"/>
<mvcSiteMapNode title="About" description="" controller="About" action="Index" iconCls="aboutIcon"/>



Route table in global


"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults

When clicking on Home or going to \ in my site, the Home node returns the root node and they never are equal


Feb 14, 2011 at 9:13 AM

Can you try this sitemap?

<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns="">
<mvcSiteMapNode title="Home" description="" controller="Home" iconCls="homeIcon">
<mvcSiteMapNode title="About" description="" controller="About" action="Index" iconCls="aboutIcon"/>
Feb 14, 2011 at 12:31 PM

I suspect it would return the root node properly, however, the hierarchy of the sitemap would be incorrect. Home and About are siblings, not a parent child relationship. 

Feb 15, 2011 at 4:29 PM

It could be you've got a parent and a child with the same title and controller?

Feb 15, 2011 at 4:56 PM

I don't think so. See my first sitemap example where the tile was root. I believe the issue lies in the equality comparison for the route values that i don't have a controller setup for the root so it thinks the second home node is more equal to the root node and since I hide the root node, the child home node will never be current. Does that make sense? 

I'm trying to find out where, exactly, this is happening in the source.. but I haven't had a lot of time to invest in searching for it at the moment. It does need to be corrected, however. 

Feb 15, 2011 at 5:51 PM

That does sound feasible.

I wonder if the process for determining children assume's a common parent controller?

Feb 15, 2011 at 6:56 PM
Edited Feb 15, 2011 at 6:57 PM

no, I don't think that's the case. I get the feeling it has to do with the route lookup and how those values are assigned to the mvcsitemapnode object. Those values are the compared to the current url route values and even though I'm on a child node of the root, it has the same route values due to the default route signature.. well, at least that's what I'm guessing. 

Mar 17, 2011 at 6:10 PM

I ended up added a dummy controller value named "Default" for simplicity.

changed my sitemap to look something like this

<mvcSiteMap xmlns="" >
	<mvcSiteMapNode title="defaulthiddenroot" controller="Default" description="" >
		<mvcSiteMapNode title="Home"  description="" controller="Home"  iconCls="homeIcon" />

The routine that looks up the root node, now ignores "home" as the root and assigns it to dummy controller.