Domain objects in (ASP.NET) session or better some kind of DTO?

We are currently placing domain objects / entities in our ASP.NET sessions.

Now we are considering the transition from InProc sessions to a public server. This requires that all objects within the session be serialized. Instead of commenting on all objects using the [Serializable] attribute, we thought about creating user session objects (DTO session objects?), Which contain only the necessary information:

CONS:

  • Entities must be reloaded, which requires additional rounds of DB

PROS:

  • Session Status Less
  • Session information is more specific (maybe CON)
  • No unnecessary annotation of domain objects

What do you think? Should we use some kind of DTO for storage inside the session, or should we stick with good old objects?

+3
source share
1 answer

If you are considering switching to ASP.NET MVC, these DTOs will become your ViewData objects for the model, which can make for easy migration.

Yes, session information will be more specific, since the DTO will be specific to the behavior of its use. This should reduce overhead in the absence of unused information or even limited information.

Specifc DTO will also help in other things; If you implement other technologies at the presentation level, such as Silverlight, Flash, etc., And you need the same objects in the web service.

+1

Source: https://habr.com/ru/post/1748651/


All Articles