I have a dynamic node provider which is copied below along with my site map configuration. When I go to my url, /Account/Edit/1475, the breadcrumb shows "Home > Accounts > [Incorrect Account Name] > Edit". It is showing an account name that is different then the 'accountId' in the url, 1475. I assume it is due to the 'preservedRouteParameter=accountId' that is causing it to match the wrong node. Is this right?
Do I need to create another DynamicNodeProvider for the Account Edit node in my sitemap? I started going down this path, but I needed to create a separate Dynamic Node Providers for most of the nodes so I thought I must be doing something wrong. Is there something I am missing in the configuration?
public class AccountDynamicNodeProvider : DynamicNodeProviderBase
{
public override IEnumerable<DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
{
using (var entities = new Entities())
{
foreach (var account in entities.TAccounts)
{
var dynamicNode = new DynamicNode("Account_" + account.AccountId, account.AccountName);
dynamicNode.RouteValues.Add("accountId", account.AccountId);
yield return dynamicNode;
}
}
}
}
Mvc.sitemap:
<mvcSiteMapNode title="Home" controller="Home" action="Index">
<mvcSiteMapNode title="Accounts" controller="Account" action="Index">
<mvcSiteMapNode title="Detail" controller="Account" action="Details" dynamicNodeProvider="my.test.namespace.AccountDynamicNodeProvider, my.assembly">
<mvcSiteMapNode title="Edit" controller="Account" action="Edit" preservedRouteParameters="accountId" />
</mvcSiteMapNode>
</mvcSiteMapNode>
</mvcSiteMapNode>
</mvcSiteMap>
This is the route that is being used:
routes.MapRoute(
name: "Account",
url: "Account/{action}/{accountId}",
defaults: new { controller = "Account", action = "Details" }
);