This project is read-only.

Defining sitemap nodes in code

In some cases, defining a sitemap node in code is more convenient than defining it in a sitemap xml file. To do this, decorate an action method with the MvcSiteMapNodeAttribute attribute. For example:

// GET: /Checkout/Complete 
[MvcSiteMapNodeAttribute(Title = "Checkout complete", ParentKey = "Checkout")] 
public ActionResult Complete(int id) 
    // ... 

Note that the ParentKey property should be specified to ensure the MvcSiteMapProvider can determine the hierarchy for all nodes. Only one node can exist without a ParentKey defined. This node will be used as the parent node for all others.

Last edited Jun 30, 2010 at 2:57 PM by maartenba, version 2


ldsenow Aug 19, 2010 at 2:33 PM 
How to define a custom url in MvcSiteMapNodeAttribute
for example:
change from /checkout/complete/{id} to /checkout/{id}/complete

maartenba Jul 29, 2010 at 12:17 PM 
Version 2.1.0 will contain that functionality. There's a description on how to do that already available in the docs:
Release for v 2.1.0 will be somewhere next week.

antonidavid Jul 29, 2010 at 11:49 AM 
Is it possible to make a node visible only in SiteMapPath, using this approach?