开发者

Should I use StructureMap or Session to manage a concrete instance?

开发者 https://www.devze.com 2023-01-05 06:25 出处:网络
I am using StructureMap on 开发者_运维技巧an ASP.NET MVC project. I have an object that I want to use throughout the session. Should I use StructureMap or Session:[\"MyObject\"] to manage the concrete

I am using StructureMap on 开发者_运维技巧an ASP.NET MVC project. I have an object that I want to use throughout the session. Should I use StructureMap or Session:["MyObject"] to manage the concrete instance? Thanks in advance.


This will depend on your scenario. If this instance is tied to a particular user and should not be shared between other users you should use Session. For example use Session to store products that the user added to his cart in an e-commerce application.

If it is for injecting dependencies such as repositories into your controllers and managing controllers StructureMap is fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消