Readonly SiteMapNodes in ASP.Net MVC?
Posted
by BenN
on Stack Overflow
See other posts from Stack Overflow
or by BenN
Published on 2009-10-05T12:58:07Z
Indexed on
2010/06/07
5:02 UTC
Read the original article
Hit count: 322
I'm using MVCSiteMap as a SiteMapProvider for my MVC site. I have a node set up like so....
<mvcSiteMapNode key="1" title="Product" controller="Product" action="Display" isDynamic="true" dynamicParameters="id">
<mvcSiteMapNode key="11" title="More Details" controller="Product" action="MoreDetails" isDynamic="true" dynamicParameters="id" />
</mvcSiteMapNode>
...Which means I can go to ~/Product/Display/12 and get a correct sitemap node for product id 12 (in this case just Product. And I can go to ~/Product/MoreDetails/12 and get the sitemap path for the MoreDetails (Product -> More Details). The problem is that the link back to Product in this sitemap doesn't work - it skips the id off the end, instead linking to ~/Product/Display/. Which sucks.
I've discovered I can edit the Title of a node using
SiteMap.CurrentNode.Title = "My New Title";
But...
SiteMap.CurrentNode.ParentNode.Url = "http://www.google.com";
Doesn't set the Url for the parent node; it gets the default link described before.
Any ideas how I can set the URL of a SiteMapNode?
© Stack Overflow or respective owner