title: Bootstrapper with Ninject using asp.net webapi
body: <p>I am trying to use Bootstrapper to do initialization for my application, ioc, automapper, configuration etc. </p>
  
  <p>I need some direction on how to setup the ninject correctly in asp.net webapi using bootstrapper. With the following configuration, my apicontroller is not able to resolve the IMyService dependency. Looks like it's using different ninject kernal.</p>
  
  <p><strong>My NinjectWebCommon</strong></p>
  
  <pre class="lang-cs prettyprint-override"><code>public static class NinjectWebCommon 
  {
      private static readonly Bootstrapper bootstrapper = new Bootstrapper();
  
      /// &lt;summary&gt;
      /// Starts the application
      /// &lt;/summary&gt;
      public static void Start() 
      {
          DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule));
          DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule));
          bootstrapper.Initialize(CreateKernel);
      }
  
      /// &lt;summary&gt;
      /// Stops the application.
      /// &lt;/summary&gt;
      public static void Stop()
      {
          bootstrapper.ShutDown();
      }
  
      /// &lt;summary&gt;
      /// Creates the kernel that will manage your application.
      /// &lt;/summary&gt;
      /// &lt;returns&gt;The created kernel.&lt;/returns&gt;
      private static IKernel CreateKernel()
      {
          var kernel = new StandardKernel();
          kernel.Bind&lt;Func&lt;IKernel&gt;&gt;().ToMethod(ctx =&gt; () =&gt; new Bootstrapper().Kernel);
          kernel.Bind&lt;IHttpModule&gt;().To&lt;HttpApplicationInitializationHttpModule&gt;();
  
          GlobalConfiguration.Configuration.DependencyResolver = new MyResolver(kernel);
  
          RegisterServices(kernel);
          return kernel;
      }
  
      /// &lt;summary&gt;
      /// Load your modules or register your services here!
      /// &lt;/summary&gt;
      /// &lt;param name="kernel"&gt;The kernel.&lt;/param&gt;
      private static void RegisterServices(IKernel kernel)
      {
      }        
  }
  </code></pre>
  
  <p><strong>bootstrapper ninject registration</strong></p>
  
  <pre class="lang-cs prettyprint-override"><code>public class DIRegistration : INinjectRegistration
  {
      public void Register(IKernel container)
      {
          container.Bind&lt;IMyService&gt;().To&lt;MyService&gt;().InTransientScope();
      }
  }
  
  public class MyService: IMyService
  {
      public string GetString()
      {
          return "My String!!!!!";
      }
  }
  
  public interface IMyService 
  {
      string GetString();
  }
  </code></pre>