Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there limits for session variables in ASP.net?

I will be populating DataTable and other controls from a complex object.

  1. Where should I store such an object?
  2. At what size does session variables starts affecting the performance of page?
like image 893
DarknessBeginsHere Avatar asked Sep 05 '25 03:09

DarknessBeginsHere


1 Answers

Data in the Session object is stored in memory on the server. Thus the storage limit is the memory available to the server. This data is not sent to the client at any stage, unless you explicitly do so. Instead the MVC code sends a cookie to the client browser once you have assigned any value to the Session object. The value of this cookie is then used to uniquely identify the session.

So...

  1. The Session object is designed specifically so that you can store session-specific data on the server, so is a suitable place for you to put session-specific data structures like you describe.
  2. Because the Session object is server-side only, using Session to store the results of computationally expensive operation that is invariant across multiple page refreshes will speed up page loads, since you can use the previous result instead of having to create it again. Unless you blow out the memory limits on the server, you're not going to see any performance degradation.
like image 72
Corey Avatar answered Sep 09 '25 02:09

Corey