Question

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 do 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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top