IoC (spring.net) with asp.net - ctor injected non-singleton objects on controller - where do I dispose?

拟墨画扇 提交于 2019-12-11 03:46:13

问题


I'm using asp.net MVC 4 - I have spring.net setup to ctor inject objects on construction of my controllers, but some of the objects aren't singletons, so I'm unsure as to how to handle the dispose method on these objects once the controller is disposed. It just feels wrong calling these objects dispose methods in the controller class as the controller class didn't construct these objects, my IoC container did. Any help would be much appreciated. Thank you.


回答1:


Consider defining Request scope for the instances that you want to be disposed at the end of a web request. See web object scopes in the spring docs for details.



来源:https://stackoverflow.com/questions/10834339/ioc-spring-net-with-asp-net-ctor-injected-non-singleton-objects-on-controlle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!