ASP.NET MVC Session usage
Posted
by Ben
on Stack Overflow
See other posts from Stack Overflow
or by Ben
Published on 2010-03-10T13:32:22Z
Indexed on
2010/03/12
10:27 UTC
Read the original article
Hit count: 310
Currently I am using ViewData or TempData for object persistance in my ASP.NET MVC application.
However in a few cases where I am storing objects into ViewData through my base controller class, I am hitting the database on every request (when ViewData["whatever"] == null).
It would be good to persist these into something with a longer lifespan, namely session. Similarly in an order processing pipeline, I don't want things like Order to be saved to the database on creation. I would rather populate the object in memory and then when the order gets to a certain state, save it.
So it would seem that session is the best place for this? Or would you recommend that in the case of order, to retrieve the order from the database on each request, rather than using session?
Thoughts, suggestions appreciated. Thanks Ben
© Stack Overflow or respective owner