How can I use Autofac in EndRequest?
You'll probably have to create your own lifetime scope. Assuming you have something this in your global.asax.cs
:
public class MvcApplication : HttpApplication{ internal static readonly IContainer ApplicationContainer = InitAutofac();}
Then you could do something like this in your EndRequest
:
using (var scope = MvcApplication.ApplicationContainer.BeginLifetimeScope()){ var service = scope.Resolve<Stuff>(); service.DoStuff();}