Been trying to get my head around using ninject in a webforms app. However i'm still puzzled as where and when to instantiate the ninjet kernel with my 'bindings module' and whether or not i need to save the kernel across the web request.
I've seen other implementations where you save the dbcontext in the global.asax event BeginRequest and any subsequent repositories get the dbcontext from there.
Would i need to d开发者_如何学JAVAo something similar with ninject or have i completely missed something.
I've read some of the suggested similar questions but haven't been able to find one that explains it so it makes sense to me.
Any help is much appreciated.
take a look at the extension Ninject.Web and an intro here.
basically your Global.asax inherits from NinjectHttpApplication
which provides an abstract CreateKernel() method.
精彩评论