This project is read-only.

Creating a first sitemap

The following is a simple sitemap XML file that can be used with the MvcSiteMapProvider:

<?xml version="1.0" encoding="utf-8" ?> 
<mvcSiteMap xmlns="" enableLocalization="true"> 
  <mvcSiteMapNode title="Home" controller="Home" action="Index" changeFrequency="Always" updatePriority="Normal"> 
    <mvcSiteMapNode title="Browse Store" controller="Store" action="Index" /> 
    <mvcSiteMapNode title="Checkout" controller="Checkout" /> 

The following attributes can be given on an XML node element:

Attribute Required? Default Description
title Yes (empty) The title of the node.
description No (empty) Description of the node.
area No (empty) The MVC area for the sitemap node. If not specified, it will be inherited from a node higher in the hierarchy.
controller Yes (empty) The MVC controller for the sitemap node. If not specified, it will be inherited from a node higher in the hierarchy.
action Yes (empty) The MVC action method for the sitemap node. If not specified, it will be inherited from a node higher in the hierarchy.
key No (autogenerated) The unique identifier for the node.
url No (autogenerated based on routes) The URL represented by the node.
roles No (empty) Comma-separated list of roles allowed to access the node and its child nodes.
resourceKey No (empty) Optional resource key.
clickable No True Is the node clickable or just a grouping node?
targetFrame No (empty) Optional target frame for the node link.
imageUrl No (empty) Optional image to be shown by supported HtmlHelpers.
lastModifiedDate No (empty) Last modified date for the node.
changeFrequency No Undefined Change frequency for the node.
updatePriority No Undefined Update priority for the node.
dynamicNodeProvider No (empty) A class name implementing MvcSiteMapProvider.Extensibility.IDynamicNodeProvider and providing dynamic nodes for the site map.
urlResolver No Sitemap provider's ISiteMapNodeUrlResolver instance Class that will be used to generate URLs for sitemap nodes.
visibilityProvider No Sitemap provider's ISiteMapNodeVisibilityProvider instance Class that will be used to determine visibility for a sitemap node.
preservedRouteParameters No (empty) Optional preserved route parameter names (= values that will be used from the current request route).
inheritedRouteParameters No (empty) Optional. Route values that should be inherited from the parent sitemap node. This is not a replacement for the SiteMapPreserveRouteDataAttribute.

Last edited Jul 6, 2011 at 12:16 PM by maartenba, version 9


TonyWallAtos Dec 1, 2011 at 4:54 PM 
Could you publish the schema file ""? It doesn't exist at the moment. Then perhaps Visual Studio would auto-complete.

erickwidya Jul 20, 2011 at 10:16 AM 
hm..does the format for the sitemap needs using mvcSiteMap and mvcSiteMapNode keyword?


kujotx Feb 8, 2011 at 10:11 PM 
Maarten - would you add the route attribute specification for 2.3.1/3.0.0, or some example of proper usage? In the meantime, I will try the files in Issue #5757 to see if they shed light on how this is done. I am trying to grok how routes/keys work to allow multiple parents per node in the backport of the route feature to 2.3.1. Thanks again. This is an excellent tool.

frankvaneykelen Dec 16, 2010 at 1:44 PM 
Please note that the value for the controller attribute is case-sensitive: an mvcSiteMapNode with controller="cases" will not show up in your sitemap when your class is named CasesController. The action and area attributes seem not to be case-sensitive though.

maartenba Nov 3, 2010 at 8:16 AM 
Thanks! No support for that one, as it requires you to update web.config on other places than just the sitemap provider. However, you can just include the resource provider mentioned in your project and MvcSiteMapProvider will automatically use it.

BrunoLopes Nov 2, 2010 at 10:58 PM 
Congrats Maartenba you really did such a great job!

Any solution for the Robink question?!

...and Robink could you post us how to customize localization providers allowing referrer external assemblies like: $Resources: AssemblyName|ClassName,Resource key' as you mentioned above.
Any help would be wonderfull...


robink Aug 21, 2010 at 1:14 AM 
It seems impossible to use localization resources which are stored in an external assembly. After some research I found out this is also the case with the default sitemap implementation from the .NET framework. The only solution I found was to create a custom localization provider which allows for localization expressions containing an assembly name, like this: ' $Resources: AssemblyName|ClassName,Resource key'. For details on how to create this custom provider read this article:
If another solution exists, I would be happy to hear it!

maartenba Aug 19, 2010 at 5:43 AM 
You can also use the built-in FilteredSiteMapNodeProvider as described here:

dsdsico Aug 18, 2010 at 11:33 PM 
I ment: beer (sending a bear to you might not be the nicest thing to do!)

dsdsico Aug 18, 2010 at 11:31 PM 
In my case, I simply need to define some child nodes that should be invisible. I could achieve this by simply writing a class that implements ISiteMapNodeVisibilityProvider, e.g. InvisibleSiteMapNodeVisibilityProvider. I think it would be good to include such a class in the MvcSiteMapProvider project. Another option could be to introduce an additional attribute: "visible". The DefaultVisibilityProvider should then check for this setting to determine whether the node should be rendered or not.

I'm very thankful for all the effort you've put into this - this sitemapprovider was really missing, and I love the fact that it supports dynamic nodes so extensively. I got a bear coming your way.

maartenba Jul 30, 2010 at 7:42 AM 

maartenba Jul 30, 2010 at 7:31 AM 
Good suggestions. Created a work item of it.

paulsuart Jul 27, 2010 at 10:00 AM 
I think a few minor issues could be addressed to make the SiteMap provider easier to use:

- When a node is added with an invalid controller, the node is excluded from the sitemap (fails silently)
- When a node is added with an invalid action, a System.ArgumentNullException ("Value cannot be null") is thrown
- When more than one node has the same title, only the first node is added to the sitemap (subsequent nodes fail silently). If title is supposed to be unique, can the documentation reflect this?
- There is no way to add a custom attribute to a node that isn't added to RouteData.

Thanks for all the effort - this is a great project in most respects.