Problem with child-nodes in dynamic mvcSiteMapNodes

Sep 8, 2010 at 6:24 PM
Edited Sep 10, 2010 at 10:20 AM


Here is my sitemap:

<mvcSiteMap xmlns="" enableLocalization="true">
    <mvcSiteMapNode title="Start" controller="Home" action="Index" changeFrequency="Always" updatePriority="Normal">
        <mvcSiteMapNode title="Products" controller="Products" action="Index" changeFrequency="Always" updatePriority="Normal">
            <mvcSiteMapNode title="_Dynamic_" action="Details" dynamicNodeProvider="Project.Web.ProductListDynamicNodeProvider, Project.Web">
                <mvcSiteMapNode title="Prices" action="Prices"/>

When you type an address:


you will get a "breadcrumb trail" like this:

Start > Products > First Product


When you type address:


 you will get an empty string...

The output should be:

Start > Products > First Product > Prices

So where could be a problem?




Sep 9, 2010 at 6:43 PM

Can you post your ProductListDynamicNodeProvider?

Sep 10, 2010 at 10:19 AM

Here you go:

    public class ProductListDynamicNodeProvider : DynamicNodeProviderBase
        public override IEnumerable<DynamicNode> GetDynamicNodeCollection()
            var cpa = (IContainerProviderAccessor)HttpContext.Current.ApplicationInstance;
            var cp = cpa.ContainerProvider;

            var productsRepository = cp.RequestLifetime.Resolve<IRepository<Product>>();

            foreach (var product in productsRepository)
                var node = new DynamicNode {Key="ProductList:" + product.Id, Title = product.Name};
                node.RouteValues.Add("id", product.Symbol);
                yield return node;
Sep 10, 2010 at 10:32 AM

Maybe I have to create another DynamicNodeProvider for my "Prices node"? And then, for each product I have to create a child-node "Price", that has a parent node named: "ProductList:" + product.Id.

Is this workaround ok?


Sep 10, 2010 at 12:26 PM

That will probably fix it.