Skip to content

Commit

Permalink
Fix for issue described in #212, preserved route parameters being wri…
Browse files Browse the repository at this point in the history
…tten to shared cache. Also fixes recursion issue where route values are being copied from the current request multiple times.
  • Loading branch information
NightOwl888 committed Aug 28, 2013
1 parent 3e8dee6 commit 42d805c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,25 @@ public override string Route
set { this.SetCachedOrMemberValue<string>(x => base.Route = x, "Route", value); }
}

protected override bool AreRouteParametersPreserved
{
get
{
var key = this.GetCacheKey("AreRouteParametersPreserved");
var result = this.requestCache.GetValue<bool?>(key);
if (result == null)
{
result = false;
}
return (bool)result;
}
set
{
var key = this.GetCacheKey("AreRouteParametersPreserved");
this.requestCache.SetValue<bool>(key, value);
}
}

#endregion

#region Protected Members
Expand Down
17 changes: 16 additions & 1 deletion src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMapNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,11 @@ public override IRouteValueDictionary RouteValues
{
get
{
this.PreserveRouteParameters();
if (this.IsReadOnly && !this.AreRouteParametersPreserved)
{
this.PreserveRouteParameters();
this.AreRouteParametersPreserved = true;
}
return this.routeValues;
}
}
Expand Down Expand Up @@ -579,6 +583,17 @@ protected virtual void PreserveRouteParameters()
}
}

/// <summary>
/// Flag to ensure the route values are only preserved from the current request a single time.
/// </summary>
/// <returns><c>true</c> if the route values have been preserved for the current request; otherwise <c>false</c>.</returns>
/// <remarks>This property must be overridden and provide an implementation that is stored in the request cache.</remarks>
protected virtual bool AreRouteParametersPreserved
{
get { return false; }
set { }
}


/// <summary>
/// Gets the route data associated with the current node.
Expand Down

0 comments on commit 42d805c

Please sign in to comment.