Are there limits for session variables in ASP.net?

怎甘沉沦 提交于 2020-01-02 08:35:10

问题


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?

回答1:


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.



回答2:


  1. If it's a per-session object, the Session dictionary is a reasonable place to store it
  2. If you are using the InProcess session store, the size of the object never affects page performance (at least until all of the data causes the process to swap). Other session stores may have a slight impact, based on how long it takes to move the data from e.g. SQL to the local process. This will be fast until your object gets really big.


来源:https://stackoverflow.com/questions/14970659/are-there-limits-for-session-variables-in-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!