title: Controller does not have a default constructor - Ninject, Owin, Web Api
body: <p>I'm migrating an MVC/WebApi application to using Owin, but after installing all the components, and moving all configuration from the globals.asax to Startup.cs i'm getting the error <code>Type 'EventController' does not have a default constructor</code>.</p>
  
  <p>It seems how i've got ninject configured isn't working correctly. Can anyone spot the error?</p>
  
  <p>EventController</p>
  
  <pre><code>public class EventController : BaseApiController
  {
      private readonly IAttendeeService attendeeService;
      private readonly IEventService eventService;
      private readonly IExcelService excelService;
  
      public EventController(IEventService eventService, IAttendeeService attendeeService, IExcelService excelService)
      {
          this.attendeeService = attendeeService;
          this.eventService = eventService;
          this.excelService = excelService;
      }
  }
  </code></pre>
  
  <p>Here's the startup.cs class</p>
  
  <pre><code>using System.Linq;
  using System.Net.Http.Formatting;
  using System.Reflection;
  using System.Web.Http;
  using System.Web.Mvc;
  using System.Web.Optimization;
  using System.Web.Routing;
  using Filanthropy.Core;
  using Filanthropy.Model.Models;
  using Filanthropy.Services;
  using Filanthropy.Web;
  using Filanthropy.Web.App_Start;
  using Microsoft.AspNet.Identity;
  using Microsoft.AspNet.Identity.EntityFramework;
  using Microsoft.Owin;
  using Microsoft.Owin.Cors;
  using Newtonsoft.Json.Serialization;
  using Ninject;
  using Ninject.Web.Common;
  using Ninject.Web.Common.OwinHost;
  using Ninject.Web.WebApi.OwinHost;
  using Owin;
  
  [assembly: OwinStartup(typeof(Startup))]
  namespace Filanthropy.Web
  {
      public partial class Startup
      {
  
          public void Configuration(IAppBuilder app)
          {
              HttpConfiguration httpConfig = new HttpConfiguration();
  
              ConfigureOAuthTokenGeneration(app);
  
              ConfigureWebApi(httpConfig);
  
              app.UseCors(CorsOptions.AllowAll);
  
              app.UseWebApi(httpConfig);
  
              app.MapSignalR();
  
              app.UseNinjectMiddleware(CreateKernel).UseNinjectWebApi(httpConfig);
  
  
              AreaRegistration.RegisterAllAreas();
              FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
              RouteConfig.RegisterRoutes(RouteTable.Routes);
              BundleConfig.RegisterBundles(BundleTable.Bundles);
              AutoMapperConfig.Configure();
          }
  
          private void ConfigureOAuthTokenGeneration(IAppBuilder app)
          {
              // Configure the db context and user manager to use a single instance per request
              app.CreatePerOwinContext(FilanthropyContext.Create);
              app.CreatePerOwinContext&lt;ApplicationUserManager&gt;(ApplicationUserManager.Create);
  
              // Plugin the OAuth bearer JSON Web Token tokens generation and Consumption will be here
  
          }
  
          private void ConfigureWebApi(HttpConfiguration config)
          {
              config.MapHttpAttributeRoutes();
  
              config.Routes.MapHttpRoute(
                 name: "DefaultApi",
                 routeTemplate: "api/{controller}/{id}",
                 defaults: new { id = RouteParameter.Optional }
                 );
  
              var jsonFormatter = config.Formatters.OfType&lt;JsonMediaTypeFormatter&gt;().First();
              jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
          }
  
          private static StandardKernel CreateKernel()
          {
              var kernel = new StandardKernel();
              kernel.Load(Assembly.GetExecutingAssembly());
  
              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)
          {
              kernel.Bind&lt;IDbContext&gt;().To&lt;FilanthropyContext&gt;().InRequestScope();
              kernel.Bind&lt;IEventService&gt;().To&lt;EventService&gt;().InRequestScope();
              kernel.Bind&lt;IAttendeeService&gt;().To&lt;AttendeeService&gt;().InRequestScope();
              kernel.Bind&lt;IProjectService&gt;().To&lt;ProjectService&gt;().InRequestScope();
              kernel.Bind&lt;IPaymentService&gt;().To&lt;PaymentService&gt;().InRequestScope();
              kernel.Bind&lt;IPledgeService&gt;().To&lt;PledgeService&gt;().InRequestScope();
              kernel.Bind&lt;IExcelService&gt;().To&lt;ExcelService&gt;();
  
              kernel.Bind&lt;IUserStore&lt;ApplicationUser&gt;&gt;()
                  .To&lt;UserStore&lt;ApplicationUser&gt;&gt;()
                  .WithConstructorArgument("context", context =&gt; kernel.Get&lt;FilanthropyContext&gt;());
          }       
  
  
      }
  }
  </code></pre>