views:

31

answers:

1

Currently we put domain objects/entities into our ASP.NET sessions.

Now we considering moving from InProc sessions to state server. This requires that all objects inside session are serializable. Instead to annotate all objects with the [Serializable] attribute, we thought about creating custom-session objects (DTO Session Objects?), which only contain the information we need:

CONS:

  • Entities must be reloaded, which requires additional DB round-trips

PROS:

  • Session State is smaller
  • Session information is more specific (could be a CON)
  • No unneeded annotation of Domain-Entities

What do you think? Should we use some kind of DTOs to store inside the session, or should we stick with good old entities?

+1  A: 

If you are thinking of moving to ASP.NET MVC, these DTO's become your Model ViewData Objects, which could make for a handy migration.

Yes, Session info wil lbe more specific as DTO's will be specific to the behaviour of it's usage. It should reduce the overhead in not having unused info or even restricted info.

Specifc DTO's will also help with other things; If you implement other technologies in your presentation layer, eg Silverlight, Flash etc and need the same objects in a webservice.

Mark Redman
In MVC projects I see the same pros and cons. To use webforms does not mean not to have a ViewModel)
Robert
@Robert: Fair enough, to me they just seem to be used more.
Mark Redman