title: Get the container instance for Simple Injector
body: <p>I am using Simple Injector with a ASP.NET MVC project. I added the <code>SimpleInjector.Integration.Web.Mvc</code> nuget package. This adds <code>SimpleInjectorInitializer</code> class in <code>App_Start</code> folder and initializes the DI. The code looks something like</p>
  
  <pre class="lang-cs prettyprint-override"><code>public static void Initialize()
  {
      // Did you know the container can diagnose your configuration? 
      // Go to: https://simpleinjector.org/diagnostics
      var container = new Container();
  
      //Container configuration code
      DependencyResolver.SetResolver(
          new SimpleInjectorDependencyResolver(container));
  }
  </code></pre>
  
  <p>This configures the DI for the MVC controller correctly. </p>
  
  <p>My question is, if I want to get the instance of the container in any of the controller\class to resolve some dependency manually how can I do it. </p>
  
  <p>I have earlier worked on AutoFac and it has a dependency interface <code>IComponentContext</code> which can be injected into any class that needs to do any resolution manually.</p>
  
  <p><strong>Update</strong>:</p>
  
  <p>Here is a scenario. My controller uses a service who initialization depends upon the input parameter passed in the controller method and hence the dependency cannot be instantiated during construction time. </p>
  
  <p>I understand that this is somewhat an anti pattern for DI, but it is requirement at few places and hence injecting the DI container is next best thing. Simple Injector samples should use of static variable to share the container which i want to avoid and also it is not possible by the way <code>SimpleInjectorInitializer</code> works.</p>