question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error with 'PreservedRouteParameters' - v4.6.22

See original GitHub issue

Hi NightOwl88,

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. I was getting this error also in the previous versions.

My configurations are: In web.config <add key="MvcSiteMapProvider_IncludeAssembliesForScan" value="XXX.XX" /> <add key="MvcSiteMapProvider_UseExternalDIContainer" value="false" /> <add key="MvcSiteMapProvider_ScanAssembliesForSiteMapNodes" value="true" /> <add key="MvcSiteMapProvider_EnableLocalization" value="true" /> <add key="MvcSiteMapProvider_CacheDuration" value="5" /> In Mvc.sitemap <?xml version="1.0" encoding="utf-8" ?> <mvcSiteMap xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-4.0" xsi:schemaLocation="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-4.0 MvcSiteMapSchema.xsd"> <mvcSiteMapNode title="$resources:Sitemap, Home" clickable="true" controller="Home" action="Index"> <mvcSiteMapNode title="$resources:Sitemap, PersonalProfile" clickable="false" > <mvcSiteMapNode title="$resources:Sitemap, PersonalProfile" controller="User" action="PersonalProfile" preservedRouteParameters="id" /> </mvcSiteMapNode> <mvcSiteMapNode title="$resources:Sitemap, Profile" clickable="false" > <mvcSiteMapNode title="$resources:Sitemap, Profile" controller="User" action="Details" preservedRouteParameters="id" /> </mvcSiteMapNode> <mvcSiteMapNode title="$resources:Sitemap, Task" clickable="true" controller="Task" action="Index"> <mvcSiteMapNode title="$resources:Sitemap, TaskDetails" controller="Task" action="Create"/> <mvcSiteMapNode title="$resources:Sitemap, TaskDetails" controller="Task" action="Edit" preservedRouteParameters="id"/> </mvcSiteMapNode> <mvcSiteMapNode title="$resources:Sitemap, Alarm" clickable="true" controller="Alarm" action="Index"> </mvcSiteMapNode> <mvcSiteMapNode title="$resources:Sitemap, Settings" clickable="false" > <mvcSiteMapNode title="$resources:Sitemap, Roles" controller="Role" action="Index"> <mvcSiteMapNode title="Details" controller="Role" action="Details" preservedRouteParameters="id"/> <mvcSiteMapNode title="$resources:Sitemap, Employees" controller="Role" action="Users" preservedRouteParameters="id"/> </mvcSiteMapNode> <mvcSiteMapNode title="$resources:Sitemap, Users" controller="User" action="Index"> <mvcSiteMapNode title="$resources:Sitemap, CreateEdit" controller="User" action="Create"/> <mvcSiteMapNode title="$resources:Sitemap, CreateEdit" controller="User" action="Edit" preservedRouteParameters="id"/> </mvcSiteMapNode> </mvcSiteMapNode> </mvcSiteMapNode> </mvcSiteMap>

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 ‘Task Details’ has ‘id’ configured in both RouteValues and PreservedRouteParameters, which is not allowed.

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?

Best regards, Lyubomir Ganchev

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:7

github_iconTop GitHub Comments

7reactions
waynebrantleycommented, Jun 23, 2016

@NightOwl888 Any chance for a fix and nuget package on this?

0reactions
PerRomancommented, Dec 1, 2017

I have the same issue. I have found MvcSiteMapProvider (version 4.6.23) in https://www.myget.org/. Please tell us, did you fix this problem in version 4.6.23? Should we use a workaround?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problems when preservedRouteParameters contains ...
I got an error like this and was confused as to why it happened. Before troubleshooting too much, try to run the code...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found