Using Action Filter Attributes - maartenba/MvcSiteMapProvider GitHub Wiki
In some situations, you may want to dynamically change the SiteMaps.Current.CurrentNode.Title in an action method. This can be done manually by setting SiteMaps.Current.CurrentNode.Title, or by adding the SiteMapTitle action filter attribute.
Imagine you are building a blog and want to use the Blog's Headline property as the site map node title. You can use the following snippet:
[SiteMapTitle("Headline")]
public ViewResult Show(int blogId) {
var blog = _repository.Find(blogId);
return View(blog);
}
You can also use a non-strong typed ViewData value as the site map node title:
[SiteMapTitle("SomeKey")]
public ViewResult Show(int blogId) {
ViewData["SomeKey"] = "This will be the title";
var blog = _repository.Find(blogId);
return View(blog);
}
There is also a Target property that allows you to set the title of the parent of the current node.
[SiteMapTitle("Headline")]
[SiteMapTitle("Category", Target = AttributeTarget.ParentNode)]
public ViewResult Show(int blogId) {
var blog = _repository.Find(blogId);
// Headline and Category are string properties of
// the blog model object.
return View(blog);
}