public ILifetimeScope Scope() { try { var contextScope = _contextManager.GetContextLifetimeScope(); if (contextScope != null) { return(contextScope); } //when such lifetime scope is returned, you should be sure that it'll be disposed once used (e.g. in schedule tasks) return(Container.BeginLifetimeScope(AutofacRequestLifetimeScopeTag)); } catch (Exception exc) { //we can get an exception here if RequestLifetimeScope is already disposed //for example, requested in or after "Application_EndRequest" handler //but note that usually it should never happen //when such lifetime scope is returned, you should be sure that it'll be disposed once used (e.g. in schedule tasks) return(Container.BeginLifetimeScope(AutofacRequestLifetimeScopeTag)); } }