title: No parameterless constructor with Ninject, both MVC and Web Api
body: <p>Before marking this as a duplicate, please take the time to read through the question!</p>
  
  <p>I have created a new web app project in VS2015, added MVC 5 and Web Api 2.</p>
  
  <p>I've added the following packages to the project:</p>
  
  <pre><code>Ninject
  Ninject.MVC5
  Ninject.Web
  Ninject.Web.Common
  Ninject.Web.Common.WebHost
  Ninject.Web.WebApi
  Ninject.Web.WebApi.WebHost
  </code></pre>
  
  <p>And that created a <code>NinjectWeb.cs</code> and <code>NinjectWebCommon.cs</code> file in the App_Start folder. With breakpoints in both, I know they get hit on start up.</p>
  
  <p>But I still get the</p>
  
  <blockquote>
    <p>No parameterless constructor defined for this object</p>
  </blockquote>
  
  <p>error when hitting a MVC controller and the</p>
  
  <blockquote>
    <p>Make sure that the controller has a parameterless public constructor.</p>
  </blockquote>
  
  <p>error when hitting a Web Api controller.</p>
  
  <p>So I have a work-around that "solves" the problem, I've added these 2 lines to the <code>CreateKernel</code> method of the <code>NinjectWebCommon.cs</code> file:</p>
  
  <pre><code>GlobalConfiguration.Configuration.DependencyResolver = new Ninject.Web.WebApi.NinjectDependencyResolver(kernel);
  System.Web.Mvc.DependencyResolver.SetResolver(new Ninject.Web.Mvc.NinjectDependencyResolver(kernel));
  </code></pre>
  
  <p>So the question: Where in the Ninject code should this have been handled? I would like to grap the code off GitHub to sort this out for good, but would like some hint as to where I should look?</p>
  
  <p><em>Edit: the content of the <code>RegisterServices</code> method:</em></p>
  
  <pre><code>private static void RegisterServices(IKernel kernel) {
  
              // Identity
              kernel.Bind&lt;IUserStore&lt;ApplicationUser&gt;&gt;()
                  .To&lt;UserStore&lt;ApplicationUser&gt;&gt;()
                  .WithConstructorArgument("connectionNameOrUrl", "User.MongoDB");
              kernel.Bind&lt;UserManager&lt;ApplicationUser&gt;&gt;()
                  .ToSelf()
                  .InRequestScope()
                  .WithConstructorArgument("store", ctx =&gt; ctx.Kernel.Get&lt;IUserStore&lt;ApplicationUser&gt;&gt;());
  
              // Services
  
              // Other
              kernel
                  .Bind&lt;IAzureSettings&gt;()
                  .To&lt;UserAzureSettings&gt;()
                  .InRequestScope();
  
              // Providers
              kernel
                  .Bind&lt;WebApiUserProvider&gt;()
                  .ToSelf();
              kernel
                  .Bind&lt;MVCUserProvider&gt;()
                  .ToSelf();
              kernel
                  .Bind&lt;IUserProvider&gt;()
                  .ToMethod((ctx) =&gt; {
                      if (HttpContext.Current.Handler.GetType().Namespace.StartsWith("System.Web.Mvc")) {
                          return ctx.Kernel.Get&lt;MVCUserProvider&gt;(new Ninject.Parameters.IParameter[] { });
                      }
                      else {
                          return ctx.Kernel.Get&lt;WebApiUserProvider&gt;(new Ninject.Parameters.IParameter[] { });
                      }
                  })
                  .InRequestScope();
          }
  </code></pre>