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.
+1
A:
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.
Darin Dimitrov
2010-06-26 07:22:19
The instance is tied to a particular user and should not be shared between other users. I know that Session will work. However, I think that the same thing can be done with StructureMap by setting the appropriate CacheBy value. Is there any advantage to using StructureMap over the Session object? Thanks.
Tarzan
2010-06-26 14:30:23
I don't see any advantage of using StructureMap for storing objects into session. Also his would make your session management code tied to a particular framework and probably more difficult to unit test. Of course without seeing actual code everything is speculation and words in the air.
Darin Dimitrov
2010-06-26 15:55:13
Thanks for your input. I'll just use Session.
Tarzan
2010-06-26 16:44:26