Get same instance of a component registered with Autofac as InstancePerLifetimeScope in Global.asax methods as is injected into a controllers?
<p>I have a situation where I need to manually instantiate some objects in <code>Application_BeginRequest</code> that are dependent on some of the same components that I've registered with Autofac. I'd like to use the same instances of components that I've registered with Autofac with <code>InstancePerLifetimeScope</code> for injection into my MVC and WebAPI controllers. My config for both MVC and Web API works as expected, and an example of a component registration looks like so:</p>

<pre><code>builder.Register(c =&gt; new MyDbContext()).AsSelf().InstancePerLifetimeScope();
</code></pre>

<p>Now I want to use that same instance in the class I'm instantiating in <code>Application_BeginRequest</code>. I've tried the following methods:</p>

<pre><code>//Tried with MVC controllers
DependencyResolver.Current.GetService&lt;MyDbContext&gt;()));
AutofacDependencyResolver.Current.ApplicationContainer.Resolve&lt;MyDbContext&gt;()));
AutofacDependencyResolver.Current.RequestLifetimeScope.Resolve&lt;MyDbContext&gt;()));
//Tried with Web API controllers
GlobalConfiguration.Configuration.DependencyResolver.GetService(typeof(MyDbContext))
</code></pre>

<p>But none give me what I'm looking for, even at later points in the request lifecylce (ie, beyond BeginRequest). As an aside, I need this to work with the Web API configuration, but I tried the first 3 methods just to see if I could get any of the resolved instances to match up with what Autofac is injecting.</p>

<p>I have what I believe is a decent understanding of lifetime scopes in Autofac and my assumption is that the instances that are being resolved for my application's controllers are in a child scope that the none of the above 4 methods are pointed towards, but it's fuzzy to me what each of the above methods is trying to do in regard to which scope they are looking at and how they decide. What's even fuzzier is what lifetime scopes Autofac is automatically creating for the components that are ultimately injected into my controllers and when they're created.</p>

<p>Clarification on the points above would be a big bonus, but my primary question here is how do I get Autofac to hand me the same instances of registered components in Global.asax that it resolves for Web API and MVC controllers?</p>