Skip to content

Commit 07d67f1

Browse files
author
Ramgopal
committed
Bug fix : throws an error when the value in name in the querystring is passed without the value
1 parent 163cab4 commit 07d67f1

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ obj/
77
packages/
88
*.user
99
*.suo
10-
*.Publish.xml
10+
*.Publish.xml
11+
/_ReSharper.DevTrends.MvcDonutCaching/

DevTrends.MvcDonutCaching/KeyGenerator.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ public string GenerateKey(ControllerContext context, CacheSettings cacheSettings
4040
{
4141
if (!routeValues.ContainsKey(formKey.ToLowerInvariant()))
4242
{
43-
routeValues.Add(formKey.ToLowerInvariant(),
44-
context.HttpContext.Request.Form[formKey].ToLowerInvariant());
43+
var item = context.HttpContext.Request.Form[formKey];
44+
routeValues.Add(formKey.ToLowerInvariant(), item != null
45+
? item.ToLowerInvariant()
46+
: string.Empty);
4547
}
4648
}
4749

@@ -50,8 +52,10 @@ public string GenerateKey(ControllerContext context, CacheSettings cacheSettings
5052
// queryStringKey is null if url has qs name without value. e.g. test.com?q
5153
if (queryStringKey != null && !routeValues.ContainsKey(queryStringKey.ToLowerInvariant()))
5254
{
53-
routeValues.Add(queryStringKey.ToLowerInvariant(),
54-
context.HttpContext.Request.QueryString[queryStringKey].ToLowerInvariant());
55+
var item = context.HttpContext.Request.QueryString[queryStringKey];
56+
routeValues.Add(queryStringKey.ToLowerInvariant(), item != null
57+
? item.ToLowerInvariant()
58+
: string.Empty);
5559
}
5660
}
5761
}

0 commit comments

Comments
 (0)