Ninject doesn't call Dispose on objects when out of scope

后端 未结 1 1288
一向
一向 2020-12-05 10:31

I was surprised to find that at least one of my objects created by Ninject is not disposed of at the end of the request, when it has been defined to be InRequestScope

<
相关标签:
1条回答
  • 2020-12-05 11:20

    Ninject will dispose your objects as soon as the request object is collected by the GC. But normally this takes some time. But there is a way to force early disposal after the request ended. The best way is to use Ninject.Web.MVC http://www.planetgeek.ch/2010/11/13/official-ninject-mvc-extension-gets-support-for-mvc3/ instead of implementing your own ControllerFactory. The other way is to configure your application to use the OnePerRequestModule.

    0 讨论(0)
提交回复
热议问题