ich bin mit: -Wie bekomme ich Ninject 2.0 mit asp.net mvc 2 arbeiten?
- asp.net Mvc rc 2
- Ninject und ninject asp.net MVC-Erweiterung (http://github.com/enkari/ninject.web.mvc)
Ich halte die ‚No parameterlosen Konstruktor für diese definiert immer Objekt.' für meinen AccountController. Dem AccountController werden Dienste hinzugefügt. Die Bindungen für diese Dienste sind im ServiceModule definiert.
Hier finden Sie den Code für meine 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(),
});
}
}
arbeiten andere Controller? Haben Sie das Ninject.Web.Mvc-Projekt gegen ASP.NET MVC 2 RC 2 erstellt? – Charlino
@Charlino. Danke, das hat funktioniert. –