A controller factory for Ninject.
public class NinjectControllerFactory : IControllerFactory { public IController CreateController(RequestContext context, string controllerName) { string typeName = "MvcApplication.Controllers." + controllerName + "Controller";
Type controllerType =
typeof(HomeController).Assembly.GetType(typeName, true, true);
return Kernel.Get(controllerType);
}
}
// Application startup ControllerBuilder.Current.SetDefaultControllerFactory(typeof(NinjectControllerFactory));
Fork
0 Feedback
You must log in before you can give any feedback
You must log in before you can post a comment


671
0




Mark 'dependency-injection' tag as 'like'
Mark 'dependency-injection' tag as 'ignore'