문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top