title: MVC 4 Web Api Controller does not have a default constructor?
body: <p>Here is the trace:</p>
  
  <pre><code>&lt;Error&gt;
     &lt;Message&gt;An error has occurred.&lt;/Message&gt;
  
     &lt;ExceptionMessage&gt;
        Type 'ProjectName.Web.Api.Controllers.ContinentsController' does not have a default constructor
     &lt;/ExceptionMessage&gt;
  
     &lt;ExceptionType&gt;System.ArgumentException&lt;/ExceptionType&gt;
  
     &lt;StackTrace&gt;
        at System.Linq.Expressions.Expression.New(Type type)
  
        at System.Web.Http.Internal.TypeActivator.Create[TBase](Type instanceType)
  
        at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(HttpRequestMessage request, Type controllerType, Func`1&amp; activator)
  
        at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)
     &lt;/StackTrace&gt;
  &lt;/Error&gt;
  </code></pre>
  
  <p>I find this weird as <code>public class UsersController : ApiController { ... }</code> is working just fine. I have compared the 2 controllers, all the settings and structures are similar.</p>
  
  <p>I am using <code>Ninject</code> and i have my system setup similar to <code>Jamie Kurtz</code> <a href="http://www.amazon.ca/gp/product/1430249773/ref=s9_simh_gw_p14_d11_i1?pf_rd_m=A3DWYIK6Y9EEQB&amp;pf_rd_s=center-4&amp;pf_rd_r=18BS0P23TZH1Q8KWS8JK&amp;pf_rd_t=101&amp;pf_rd_p=1375923642&amp;pf_rd_i=915398" rel="noreferrer">Asp.Net Mvc 4 and the Web Api: Building a REST Service from Start to Finish</a>.</p>
  
  <p>From the stack trace, is anyone able to spot the problem and how to solve it? Thanks!</p>
  
  <p><strong><em>As Requested.</em></strong></p>
  
  <p><strong>ContinentsController</strong>         </p>
  
  <pre><code>[LoggingNHibernateSession]
  public class ContinentsController : ApiController
  {
      private readonly ISession _session;
      private readonly IContinentMapper _continentMapper;
      private readonly IHttpContinentFetcher _httpContinentFetcher;
      private readonly IDateTime _dateTime;
  
      public ContinentsController(ISession session, IContinentMapper continentMapper, IHttpContinentFetcher continentFetcher, IDateTime dateTime)
      {
          _session = session;
          _continentMapper = continentMapper;
          _httpContinentFetcher = continentFetcher;
          _dateTime = dateTime;
      }
  
      public IEnumerable&lt;Continent&gt; Get()
      {
          var continents = _session
              .Query&lt;Data.Model.Continent&gt;()
              .Select(_continentMapper.CreateContinent)
              .ToList();
  
          return continents;
      }
  
      public Continent Get(long id)
      {
          var modelContinent = _httpContinentFetcher.GetContinent(id);
          var continent = _continentMapper.CreateContinent(modelContinent);
  
              return continent;
          }
    }
  </code></pre>
  
  <p><strong>UsersController</strong>: Works just fine.</p>
  
  <pre><code>    public class UsersController : ApiController
      {
          private readonly ISession _session;
          private readonly IUserManager _userManager;
          private readonly IUserMapper _userMapper;
          private readonly IHttpUserFetcher _userFetcher;
  
          public UsersController(
              IUserManager userManager,
              IUserMapper userMapper,
              IHttpUserFetcher userFetcher,
              ISession session)
          {
              _userManager = userManager;
              _userMapper = userMapper;
              _userFetcher = userFetcher;
              _session = session;
          }
  
          [Queryable]
          public IQueryable&lt;Data.Model.User&gt; Get()
          {
              return _session.Query&lt;Data.Model.User&gt;();
          }
  
          [LoggingNHibernateSession]
          public User Get(Guid id)
          {
              var user = _userFetcher.GetUser(id);
              return _userMapper.CreateUser(user);
          }
      }
  </code></pre>
  
  <p>I am using <code>NinjectWebCommon.cs</code> and in it, i have this and a few other default methods.:</p>
  
  <pre><code>        private static void RegisterServices(IKernel kernel)
          {
              var containerConfigurator = new NinjectConfigurator();
              containerConfigurator.Configure(kernel);
  
              GlobalConfiguration.Configuration.MessageHandlers.Add(kernel.Get&lt;BasicAuthenticationMessageHandler&gt;());
          }
  </code></pre>
  
  <p>Then i have <code>NinjectConfigurator.cs</code>:</p>
  
  <pre><code>public class NinjectConfigurator
  {
      ......
      private void AddBindings(IKernel container)
          {
              .....
              container.Bind&lt;IDateTime&gt;().To&lt;DateTimeAdapter&gt;();
              container.Bind&lt;IDatabaseValueParser&gt;().To&lt;DatabaseValueParser&gt;();
  
              //HttpFetchers
              container.Bind&lt;IHttpUserFetcher&gt;().To&lt;HttpUserFetcher&gt;();
              container.Bind&lt;IHttpContinentFetcher&gt;().To&lt;HttpContinentFetcher&gt;();                                
  
              //TypeMappers
              container.Bind&lt;IUserManager&gt;().To&lt;UserManager&gt;();
              container.Bind&lt;IMembershipInfoProvider&gt;().To&lt;MembershipAdapter&gt;();
              container.Bind&lt;IUserMapper&gt;().To&lt;UserMapper&gt;();
              container.Bind&lt;IContinentMapper&gt;().To&lt;ContinentMapper&gt;();    
              .........
          }
       .......
  }
  </code></pre>
  
  <p>Both <code>NinjectWebCommon.cs</code> and <code>NinjectConfigurator.cs</code> are located in the <code>App_Start</code> folder. </p>
  
  <p><code>container.Bind&lt;ISession&gt;().ToMethod(CreateSession);</code> is <code>NHibernate</code>. It is within <code>NinjectConfigurator.cs</code> inside <code>private void ConfigureNHibernate(IKernel container) { ... }</code></p>