DynamicNodeProvider causes breadcrumbs to disappear

Jun 20, 2011 at 3:37 PM
Edited Jun 20, 2011 at 3:39 PM

I am trying to use MvcSiteMapProvider to generate a breadcrumb trail for my website. I have some pages that require an ID to be passed in the URL, so I'm trying to use dynamic nodes to accomplish this. However, for all the nodes that I declare as dynamic, no breadcrumbs appear on the respective page. I am also getting an interesting error when I debug with a breakpoint in my DynamicNodeProvider class. Here is a basic version of the class, and the sitemap:

 

public class UserSummaryDynamicNodeProvider : DynamicNodeProviderBase
{
    private static ServiceClient proxy = new ServiceClient();
    List<User> users = proxy.GetUsers();

    public override IEnumerable<DynamicNode> GetDynamicNodeCollection()
    {
        var nodes = new List<DynamicNode>();

        foreach (var user in users)
        {
            DynamicNode node = new DynamicNode();
            node.Key = "UserSummary";
            node.ParentKey = "UserMenu";
            node.RouteValues.Add("userID", user.ID);

            nodes.Add(node);
        }

        return nodes;
    }
}

 

<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-3.0" enableLocalizatoin="true">
    <mvcSiteMapNode title="Home"  controller="Home" action="Index">
        <mvcSiteMapNode title="User Menu" controller="UserInfo" action="UserMenu">
            <mvcSiteMapNode title="User Summary" controller="UserInfo" action="UserSummary" dynamicNodeProvider="MySite.Users.DynamicNodeProviders.UserSummaryDynamicNodeProvider, MySite.Users" />
        </mvcSiteMapNode>
    </mvcSiteMapNode>
</mvcSiteMap>

 

The error I get says "No Source Available" and appears to be looking for a specific C# source file (MvcSiteMapNode.cs) in a location I haven't specified (c:\Projects\Codeplex\TFS10\mvcsitemap\Branches\3.1.0\src\MvcSiteMapProvider\MvcSiteMapProvider). I downloaded the MvcSiteMapProvider via NuGet, and this class is included in the reference object, but the source files aren't included individually in the download. I've included the appropriate assembly references (both MvcSiteMapProvider and MvcSiteMapProvider.Extensibility). Am I missing something obvious here?

This might not be my only problem here. Before I tried using dynamic nodes, I tried adding the [SiteMapPreserveRouteData] attribute to my action results, but that didn't work either. In that case the breadcrumb still appears, but none of the ID parameters in the route are preserved. Any ideas why that wouldn't work? Just to clarify, I'm using MVC3 and .NET 4.0

Please let me know if I need to provide some more info.

Coordinator
Jun 29, 2011 at 11:33 AM

Any stacktraces / error messages?