0

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.

Tarzan
  • 4,270
  • 8
  • 50
  • 70

1 Answers1

1

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
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • 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 Jun 26 '10 at 14:30
  • 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 Jun 26 '10 at 15:55
  • Thanks for your input. I'll just use Session. – Tarzan Jun 26 '10 at 16:44