I recently followed Aaron Powell's posts on supporting MVC controllers with Umbraco 4: http://www.aaron-powell.com/umbraco/using-mvc-in-umbraco-4 and http://www.aaron-powell.com/umbraco/using-mvc-in-umbraco-4-revisited
Everything works as expected. I can set up controllers and they work seamlessly well along side umbraco's pages. The thing is I'm trying to setup IoC with Ninject and haven't been able to get it working.
I've setup a class in App_Start that uses web activator to attach to the PreApplicationStartMethod and defined my kernel configuration as I have always had in the past:
private static IKernel CreateKernel()
{
var kernel = new StandardKernel();
//Standard Modules
kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();
kernel.Bind<IUnitOfWork>().To<UnitOfWork>().InRequestScope();
kernel.Bind<IConfigurationManager>().To<ConfigurationManagerWrapper>().InRequestScope();
//Security
kernel.Bind<ISecurity>().To<Security>().InSingletonScope();
kernel.Bind<IMembershipAuthorization>().To<MembershipAuthorization>();
kernel.Bind<IFormsAuthorization>().To<FormsAuthorization>();
//Registering my services, repositories, and connections
RegisterRepositories(kernel);
RegisterServices(kernel);
RegisterConnections(kernel);
GlobalConfiguration.Configuration.DependencyResolver = new NinjectResolver(kernel);
return kernel;
}
I've debugged the solution and this code gets run. But everytime I call a controller the injection isn't made and I get the "No parameterless constructor is defined" error.
Does anyone know how to get IoC working in this scenario?