Skip to content

Commit 682ac8a

Browse files
committed
Fixing issue #36
1 parent 054ec38 commit 682ac8a

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

DevTrends.MvcDonutCaching/KeyGenerator.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ namespace DevTrends.MvcDonutCaching
1010
{
1111
public class KeyGenerator : IKeyGenerator
1212
{
13-
private const string RouteDataKeyAction = "action";
14-
private const string RouteDataKeyController = "controller";
15-
private const string DataTokensKeyArea = "area";
13+
internal const string RouteDataKeyAction = "action";
14+
internal const string RouteDataKeyController = "controller";
15+
internal const string DataTokensKeyArea = "area";
1616

1717
private readonly IKeyBuilder _keyBuilder;
1818

@@ -26,6 +26,12 @@ public KeyGenerator(IKeyBuilder keyBuilder)
2626
_keyBuilder = keyBuilder;
2727
}
2828

29+
/// <summary>
30+
/// Generates a key given the <see cref="context"/> and <see cref="cacheSettings"/>.
31+
/// </summary>
32+
/// <param name="context">The controller context.</param>
33+
/// <param name="cacheSettings">The cache settings.</param>
34+
/// <returns>A string that can be used as an output cache key</returns>
2935
[CanBeNull]
3036
public string GenerateKey(ControllerContext context, CacheSettings cacheSettings)
3137
{

DevTrends.MvcDonutCaching/OutputCacheManager.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,17 @@ public void RemoveItems([AspMvcController] string controllerName, [AspMvcAction]
159159
{
160160
foreach (var routeValue in routeValues)
161161
{
162+
// Ignoring the "area" part of the route values if it's an empty string
163+
// Ref : https://github.com/moonpyk/mvcdonutcaching/issues/36
164+
if (routeValue.Key == KeyGenerator.DataTokensKeyArea)
165+
{
166+
var areaString = routeValue.Value as string;
167+
if (string.IsNullOrWhiteSpace(areaString))
168+
{
169+
continue;
170+
}
171+
}
172+
162173
var keyFrag = _keyBuilder.BuildKeyFragment(routeValue);
163174

164175
if (string.IsNullOrEmpty(keyFrag))

0 commit comments

Comments
 (0)