DynamicNodeProvider not working in XML but works in Attribute?

Dec 9, 2010 at 1: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" />    

</mvcSiteMapNode>  

</mvcSiteMapNode>

</mvcSiteMap>

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!

Coordinator
Dec 23, 2010 at 11:25 AM

Can you post your CropTypeDynamicNodeProvider?

Jan 5, 2011 at 4: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.

Coordinator
Jan 6, 2011 at 7:17 AM

WOuld it be possible to create a small reproduction app?

Jun 16, 2011 at 3: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.

Thanks

Coordinator
Jun 29, 2011 at 11:32 AM

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