<PackageReference Include="Castle.Windsor" Version="4.1.0" />

WebRequestScopeAccessor

using Castle.MicroKernel.Context; using Castle.MicroKernel.Lifestyle.Scoped; using System; namespace Castle.MicroKernel.Lifestyle { public class WebRequestScopeAccessor : IScopeAccessor, IDisposable { public void Dispose() { PerWebRequestLifestyleModule.YieldScope()?.Dispose(); } public ILifetimeScope GetScope(CreationContext context) { return PerWebRequestLifestyleModule.GetScope(); } } }