incorrect CurrentNode being returned

Feb 11, 2011 at 11:41 PM

MC2, MVCSitemap v2.3.1

Hi,

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

sitemap

 

<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-2.0" >
<mvcSiteMapNode title="root">
<mvcSiteMapNode title="Home" description="" controller="Home" iconCls="homeIcon"/>
<mvcSiteMapNode title="About" description="" controller="About" action="Index" iconCls="aboutIcon"/>
</mvcSiteMapNode>
</mvcSiteMap>


I've tried this too

 

<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-2.0" >
<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"/>
</mvcSiteMapNode>
</mvcSiteMap>

 


 

Route table in global

 

routes.MapRoute(
"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

 

Coordinator
Feb 14, 2011 at 8:13 AM

Can you try this sitemap?

<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-2.0">
<mvcSiteMapNode title="Home" description="" controller="Home" iconCls="homeIcon">
<mvcSiteMapNode title="About" description="" controller="About" action="Index" iconCls="aboutIcon"/>
</mvcSiteMapNode>
</mvcSiteMap>
Feb 14, 2011 at 11:31 AM

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 3:29 PM

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

Feb 15, 2011 at 3: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 4:51 PM

That does sound feasible.

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

Feb 15, 2011 at 5:56 PM
Edited Feb 15, 2011 at 5: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 5:10 PM

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

changed my sitemap to look something like this

<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-2.0" >
	<mvcSiteMapNode title="defaulthiddenroot" controller="Default" description="" >
		<mvcSiteMapNode title="Home"  description="" controller="Home"  iconCls="homeIcon" />
        </mvcSiteMapNode>
</mvcSiteMap>


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