问题
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