0

I am using mvcsitemapprovider in breadcrumbs. In certain section of the website, I want to show child nodes only if the parameters meet certain conditions. All nodes are already defined in Mvc.sitemap. I just want to hide them until URL parameters meet the requirement.

I want to know if DynamicNodeProvider is the only option I have. Can't I show/hide few nodes at runtime?

Please help.

sarojanand
  • 607
  • 1
  • 11
  • 30

1 Answers1

0

There are 2 options:

  1. Enable security trimming and decorate your controller actions with the [Authorize] attribute. This will only work if your "certain conditions" coincide with user roles.
  2. Use a custom visibility provider for your custom logic. You can use custom attributes, data passed from the UI layer through the sourceMetaData dictionary, the HttpContext.Current object, or whatever other data source you need to get the visibility behavior you require.

For the second option, I would recommend setting the MvcSiteMapProvider_VisibilityAffectsDescendants setting to false so your nodes will toggle visibility without being affected by their ancestor nodes.

IDynamicNodeProvider is not an option to get this kind of behavior. Dynamic nodes are nodes that are potentially loaded from a dynamic data source, but they are still loaded into a shared cache at application startup. They are not loaded per request. You can, however, use both of the above options with IDynamicNodeProvider.

NightOwl888
  • 55,572
  • 24
  • 139
  • 212