From 4720381d781898021f8cc4b138ed35dc8c1c560a Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Fri, 31 Oct 2014 18:06:11 -0700 Subject: [PATCH] Change the IRazorCompilationService's DI lifetime. - Modified the MvcServices registration of IRazorCompilationService to be transient to ensure the IMvcRazorHost does not maintain state. --- .../Razor/RazorCompilationService.cs | 3 --- src/Microsoft.AspNet.Mvc/MvcServices.cs | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNet.Mvc.Razor/Razor/RazorCompilationService.cs b/src/Microsoft.AspNet.Mvc.Razor/Razor/RazorCompilationService.cs index a6a34eb1f2..baa5c820e1 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/Razor/RazorCompilationService.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/Razor/RazorCompilationService.cs @@ -9,9 +9,6 @@ namespace Microsoft.AspNet.Mvc.Razor /// /// Default implementation of . /// - /// - /// This class must be registered as a singleton service for the caching to work. - /// public class RazorCompilationService : IRazorCompilationService { private readonly ICompilationService _compilationService; diff --git a/src/Microsoft.AspNet.Mvc/MvcServices.cs b/src/Microsoft.AspNet.Mvc/MvcServices.cs index c9e2e0b174..5ff07e2edc 100644 --- a/src/Microsoft.AspNet.Mvc/MvcServices.cs +++ b/src/Microsoft.AspNet.Mvc/MvcServices.cs @@ -125,9 +125,9 @@ namespace Microsoft.AspNet.Mvc yield return describe.Singleton(); // Both the compiler cache and roslyn compilation service hold on the compilation related - // caches. RazorCompilation service is just an adapter service, and it is scoped - // since it will typically be resolved multiple times per request. - yield return describe.Scoped(); + // caches. RazorCompilation service is just an adapter service, and it is transient to ensure + // the IMvcRazorHost dependency does not maintain state. + yield return describe.Transient(); // The ViewStartProvider needs to be able to consume scoped instances of IRazorPageFactory yield return describe.Scoped();