Change the IRazorCompilationService's DI lifetime.

- Modified the MvcServices registration of IRazorCompilationService to be transient to ensure the IMvcRazorHost does not maintain state.
This commit is contained in:
N. Taylor Mullen 2014-10-31 18:06:11 -07:00 committed by NTaylorMullen
parent 30884d8d26
commit 4720381d78
2 changed files with 3 additions and 6 deletions

View File

@ -9,9 +9,6 @@ namespace Microsoft.AspNet.Mvc.Razor
/// <summary>
/// Default implementation of <see cref="IRazorCompilationService"/>.
/// </summary>
/// <remarks>
/// This class must be registered as a singleton service for the caching to work.
/// </remarks>
public class RazorCompilationService : IRazorCompilationService
{
private readonly ICompilationService _compilationService;

View File

@ -125,9 +125,9 @@ namespace Microsoft.AspNet.Mvc
yield return describe.Singleton<ICompilationService, RoslynCompilationService>();
// 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<IRazorCompilationService, RazorCompilationService>();
// 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<IRazorCompilationService, RazorCompilationService>();
// The ViewStartProvider needs to be able to consume scoped instances of IRazorPageFactory
yield return describe.Scoped<IViewStartProvider, ViewStartProvider>();