Skip to content

Commit

Permalink
Fix for using preservedRouteParameters so they will work whether the …
Browse files Browse the repository at this point in the history
…value is provided as part of the route or part of the query string.

The route value collection contained an empty value for "id" (which was configured in the route as optional). This caused the route value to take precedence even though it was empty. To match the behavior MVC, the query string value was made to overwrite the route value in this case. Route values still take precedence over query string values when both are provided.
  • Loading branch information
NightOwl888 committed Jul 30, 2014
1 parent 5a961be commit 6e10aef
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMapNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,9 @@ protected virtual IDictionary<string, object> MergeRouteValuesAndNamedQueryStrin
{
// Copy the query string value as a route value if it doesn't already exist
// and the name is provided as a match. Note that route values will take
// precedence over query string parameters in cases of duplicates.
if (key != null && queryStringKeys.Contains(key) && !result.ContainsKey(key))
// precedence over query string parameters in cases of duplicates
// (unless the route value contains an empty value, then overwrite).
if (key != null && queryStringKeys.Contains(key) && (!result.ContainsKey(key) || string.IsNullOrEmpty(result[key].ToString())))
{
result[key] = queryStringValues[key];
}
Expand Down

0 comments on commit 6e10aef

Please sign in to comment.