GetDynamicNodeCollection() never called

Jan 20, 2011 at 8:19 PM

Hi guys,

I have this problem with dynamicNodeProvider and my implementation of DynamicNodeProviderBase.

Everything seems to be properly defined an all (no errors), but my dynamic nodes does not show up!

Here's the Mvc.sitemap (the important bits):

<mvcSiteMapNode title="Browse" controller="Presenter" action="Index">
  <mvcSiteMapNode title="Details" action="Present" dynamicNodeProvider="PresentaSearch.Utils.ItemDetailsDynamicNodeProvider, PresentaSearch" />

and here is the ItemDetailsDynamicNodeProvider class:


public class ItemDetailsDynamicNodeProvider : DynamicNodeProviderBase
    public override IEnumerable<DynamicNode> GetDynamicNodeCollection()
        var repository = new Repository();

        foreach (var item in repository.GetItems())
            DynamicNode node = new DynamicNode(item.Slug, item.DisplayName);
            node.RouteValues.Add("id", item.Slug);


            yield return node;

If I set a breakpoint at GetDynamicNodeCollection(), it will never be reached when I first launch the sitemap.xml file!

I'm very frustrated that there is no error message to guide me, and I was hoping you could do so :) Where could there be an error? In the controllers, with the routing or what?!

Thanks in advance!


Jan 21, 2011 at 2:18 PM

Can you reproduce this in a small project? The code you posted looks like it should work...

Jan 21, 2011 at 6:15 PM

I got it to work in a sample project using a simple for-loop with the int as id.

Then I changed it to my repository again and then no nodes showed up in the sitemap!

So I tried to limit the number of nodes, like this:

public override IEnumerable<DynamicNode> GetDynamicNodeCollection()
    var repository = new Repository();
    int i = 186;

    var items = repository.GetItems();

    foreach (var item in items)
        if (i == 0) break;
        var node = new DynamicNode(item.Slug, item.DisplayName);
        node.RouteValues.Add("slug", item.Slug);

        yield return node;

The wierd thing is that this works, but if I set i to 187, then I have NO NODES again...

So what's up, is there a max limit of nodes in a sitemap or something?

Jan 21, 2011 at 7:26 PM

I think we found the answer to our problem.

It appears that the same slug existed for 2 different items.

Even though it is an error from our side I think MvcSiteMapProvider was kinda harsh just to not output any nodes at all (and no error)... :)

Nov 13, 2012 at 2:11 AM

I'm experiencing the same exact issue.

Could you please gimme a hand?

Thank you!