Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Error with 'PreservedRouteParameters' - v4.6.22 #424
I am using 4.6.22 version of MVCSiteMapProvider. Linked to #382 I still get this error with both using parameter in RouteValues and PreservedRouteParameters, which is not allowed.
My configurations are:
My full error is:
The node with key 'Home_Index_GET$resources:Sitemap, Home__Task_Index_GET_$resources:Sitemap, Task__Task_Edit_GET_$resources:Sitemap, TaskDetails_' and title
PreservedRouteParameters copies the route value from the current HTTP request which would overwrite your configured RouteValue in every case. Either remove 'id' from PreservedRouteParameters or as a configured RouteValue.
Alternatively, if you are configuring the node in XML and intend to use 'id' as a custom attribute, use the 'MvcSiteMapProvider_AttributesToIgnore' configuration setting to ensure 'id' is not automatically added to RouteValues. If using external DI, this setting is injected into the constructor of 'SiteMapXmlReservedAttributeNameProvider'.
This error occurs randomly and there is no specific way to reproduce it all the time. Is there anything that I am doing wrong?
Your issue is actually a duplicate of #310. The issue here is that when the cache expires at the precise moment when a request is being made + more than one HTML helper on the page, the SiteMap is unloaded between HTML helper requests, but the request caching done on the
I am actually a little surprised that people haven't complained more about this. I have been holding off to have enough changes to make a minor release (since this will break external DI configurations), but as of late I haven't had much time to contribute.
In the meantime, there is a workaround you can use by wrapping the existing
Note on using the suggested workaround in combination with dependency injection: the class interface and constructor make the DI resolver recurse endlessly.
I changed it to
And in the MvcSiteMapProviderContainerExtension use
@Adam-78 Not sure if this will help you, but I did figure out why it was happening on my site. In my layout page, I would generate the top navigation menu, then everything else for the page, and finally I would render my site's footer menu. The error would happen if someone got unlucky and requested a page, navigation menu would generate, and while the body of the page was loading the menu's cache expired, and it would then attempt to render the site's footer menu and fail.
My fix was to just generate both the navigation and footer menus at the same time into variables, and use those variables where they should be rendered. Haven't seen this error pop up again in about 2 months.
No idea if your setup is similar, but hopefully this helps somebody.