I am trying to develop a sitemap for my site that supports URL parameters when necessary. I am using MvcSiteMapProvider and trying to use dynamic nodes to save route data for different nodes. However, the problem I am facing is related to children of dynamic nodes. When I install a node in a dynamic node in a Sitemap, it does not appear in the Sitemap generated using Html.MvcSiteMap (). SiteMap (), and when I go to the page, I lose all the breadcrumbs in front of the dynamic node.
For example, if my dynamic node is called Character Details, it looks on the Character Details page:
Home > People > Person Details
But as soon as I move further to the page, say โContact personโ, the palette looks like this:
Person Details > Contact Person
without the first two ways. Also, if I try to return to Person Details, none of the url parameters will be saved (for example, instead of going to http: // localhost: 55555 / Home / People / PersonDetails? Id = 12 , it goes to http: // localhost : 55555 / Home / People / PersonDetails ).
When I try to display the entire sitemap using Html.MvcSiteMap (). SiteMap () returns the correct hierarchy before the dynamic node. The site map contains a unique node for each "Person" node found in the dynamic node provider, but does not display any of the children of the dynamic node.
My sitemap looks something like this (abbreviated):
<?xml version="1.0" encoding="utf-8" ?> <mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-3.0" enableLocalization="true"> <mvcSiteMapNode title="Home" controller="Home" action="Index"> <mvcSiteMapNode title="People" controller="Information" action="People"> <mvcSiteMapNode title="Person Details" controller="Information" action="PersonDetails" dynamicNodeProvider="MySite.Code.PersonDetailsDynamicNodeProvider, MySite"> <mvcSiteMapNode title="Contact Person" controller="Information" action="Contact" /> </mvcSiteMapNode> </mvcSiteMapNode> </mvcSiteMapNode> </mvcSiteMap>
And my dynamic node provider is as follows:
public class PersonDetailsDynamicNodeProvider : DynamicNodeProviderBase { List<Person> people = proxy.GetPeople(); public override IEnumerable<DynamicNode> GetDynamicNodeCollection() { var nodes = new List<DynamicNode>(); foreach (var person in people) { DynamicNode node = new DynamicNode(); node.RouteValues.Add("id", person.ID); nodes.Add(node); } return nodes; } static private PersonServiceClient proxy = new PersonServiceClient(); }
Is there anything I don't see? I have the feeling that I just left something, but I am very new to website development and actually just shudder in the dark right now.