From 5fe09f9df42aa54baf36fa203552fc547cce3132 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Mon, 10 Jul 2017 17:28:40 -0700 Subject: [PATCH 1/2] Upgrade Roslyn to 2.3.0-beta4-* (#6523) --- build/dependencies.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index 9476d12300..cc88f5fcca 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -12,7 +12,7 @@ 4.7.49 2.0.0-* 2.0.0-* - 2.3.0-beta3-* + 2.3.0-beta4-* 2.0.0-* 15.3.0-* 5.2.2 From 0c07e1e725e8bf20b2dc840f7e02945d19913661 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Mon, 10 Jul 2017 17:54:46 -0700 Subject: [PATCH 2/2] [Fixes #6522] Commit cache entries only when the content gets successfully generated --- .../CacheTagHelper.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Mvc.TagHelpers/CacheTagHelper.cs b/src/Microsoft.AspNetCore.Mvc.TagHelpers/CacheTagHelper.cs index 7984e1fc19..e42bb67883 100644 --- a/src/Microsoft.AspNetCore.Mvc.TagHelpers/CacheTagHelper.cs +++ b/src/Microsoft.AspNetCore.Mvc.TagHelpers/CacheTagHelper.cs @@ -119,8 +119,8 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers // Use the CreateEntry to ensure a cache scope is created that will copy expiration tokens from // cache entries created from the GetChildContentAsync call to the current entry. IHtmlContent content; - using (var entry = MemoryCache.CreateEntry(cacheKey)) - { + var entry = MemoryCache.CreateEntry(cacheKey); + // The result is processed inside an entry // such that the tokens are inherited. @@ -130,9 +130,12 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers entry.SetOptions(options); entry.Value = result; - } tcs.SetResult(content); + // An entry gets committed to the cache when disposed gets called. We only want to do this when + // the content has been correctly generated (didn't throw an exception). For that reason the entry + // can't be put inside a using block. + entry.Dispose(); return content; } catch (Exception ex)