I use: -
I keep getting "No parameterless constructor defined for this object." for my AccountController. Services are entered into the AccountController. Associations for these services are defined in the ServiceModule.
Find below code for my MvcApplication in Global.asax.cs.
public class MvcApplication : NinjectHttpApplication // System.Web.HttpApplication { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Account", action = "Login", id = "" } // Parameter defaults ); } protected override void OnApplicationStarted() { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); RegisterAllControllersIn(Assembly.GetExecutingAssembly()); } protected override IKernel CreateKernel() { return new StandardKernel(new INinjectModule[] { new ServiceModule(), }); } }
dependency-injection asp.net-mvc ninject asp.net-mvc-2
Jitesh patil
source share