DynamicNodeProvider not working in XML but works in Attribute?

Dec 9, 2010 at 2:08 AM

I am getting this weird bug which I cannot figure out after a bunch of testing.


<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-2.0" enableLocalization="true">  

<mvcSiteMapNode key="Home" title="Home" controller="Home" action="Index" changeFrequency="Always" updatePriority="Normal" >  

  <mvcSiteMapNode title="Map" area="Map" controller="Map" action="Index"/>    

<mvcSiteMapNode key="Recipe" title="Recipes" area="Recipe" controller="Recipe" action="Index"/>  

  <mvcSiteMapNode key="CropType" title="Crop Guide" area="Crop" controller="CropType" action="Index" >      

<mvcSiteMapNode title="Details" area="Crop" controller="CropType" action="Details" dynamicNodeProvider="namespace.CropTypeDynamicNodeProvider, assemblyName" />    




The breadcrumb does not come up when I go to the {Details/id} page.


However, if I take the dynamicNodeProvider out of the XML and put it as an attribute within the controller it works.

[MvcSiteMapNodeAttribute(ParentKey="CropType", DynamicNodeProvider = "namespace.CropTypeDynamicNodeProvider, assemblyName")]

public ActionResult Details(int id) {   }


The problem I have with the attribute method is my next level breadcrumb "ParentKey" is built dynamically.  I cannot set the ParentKey within the controller.

Any help would be appreciated.  Thanks!

Dec 23, 2010 at 12:25 PM

Can you post your CropTypeDynamicNodeProvider?

Jan 5, 2011 at 5:22 PM


public class CropTypeDynamicNodeProvider : DynamicNodeProviderBase  


private Entities db = new Entities();

 public override IEnumerable<DynamicNode> GetDynamicNodeCollection()        


// Create a node for each genre            

foreach (var cropType in db.hf_CropType)          


DynamicNode node = new DynamicNode("CropType" + cropType.Id, NavigationHelper.ToFriendlyBreadCrumbName(cropType.Name));                                             

node.RouteValues.Add("id", cropType.Id);              

 yield return node;           






I also notice this bug for the breadcrumbs.  Basically, if you have a DynamicNode title that has spaces in between words like "Sample Section", the breadcrumb feature breaks.  I would have to convert the string to "Sample-Section" for the breadcrumb to show up.

Jan 6, 2011 at 8:17 AM

WOuld it be possible to create a small reproduction app?

Jun 16, 2011 at 4:22 AM

Wondering if a solution ever surfaced for this. I seem to be experiencing the same issue. Dynamic provider works fine as long as no spaces between url words. If there is a space in a segment, then no breadcrumbs display.


Jun 29, 2011 at 12:32 PM

@MrHaro, can you describe that behaviour? May help in pinning down the issue...