Ninject in ASP.NET MVC4

前端 未结 8 1949
终归单人心
终归单人心 2021-02-07 03:19

So after much screwing around I finally got Ninject wired in and compiling in my MVC4 application. The problem I was running into is the IDependencyScope interface no longer ex

8条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-07 03:58

    When you will install latest Ninject.MVC3 from NuGet package we find following code on top of the NinjectWebCommon.cs file:

    [assembly: WebActivator.PreApplicationStartMethod(typeof(MvcApplication1.App_Start.NinjectWebCommon), "Start")]
    
    [assembly: WebActivator.ApplicationShutdownMethodAttribute(typeof(MvcApplication1.App_Start.NinjectWebCommon), "Stop")]
    

    in this case we dont need to register ninject explicitly in global.asax

    I found a good content on using Ninject with MVC 4 here

提交回复
热议问题