I am working on a project in .Net MVC3 using MVC SiteMap Provider for creating the menus.
Some of the menu nodes should be visible only when a specific route parameter (meetingId) is set, see example below:
<mvcSiteMapNode controller="MeetingAttendants" action="Index" title="Attendants" preservedRouteParameters="meetingId" />
The meetingId parameter is a non-nullable int, that has no default value. The parameter is set when browsing information about a meeting.
When loading a page where the parameter is not set, an error is thrown:
Could not resolve URL for sitemap node Attendants which represents action Index in controller MeetingAttendants. Ensure that the route for this sitemap node can be resolved and that its default values allow resolving the URL for the current sitemap node.
I have tried setting a default value when mapping the routes, and that makes the problem go away. But is there anyway to solve this problem without setting a default value (as there should be no default value)?
I am unsure why the default implementation of the resolver behaves this way. Have a look at my issue about this - as well as an easy fix using a small change to your own SiteMapNodeUrlResolver (as it seems you did).
Hoping to get some feedback and maybe get this changed in the defaults?
https://github.com/maartenba/MvcSiteMapProvider/issues/115