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


520
0




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