Storing a DataSet in ViewState or Session State

I am currently storing a DataSet in a ViewState, but this may affect page performance.

Can you suggest me if I can use Session or ViewState or any alternative with which it does not affect performance?

+4
source share
4 answers

Why do you need to store the entire data set? If you need to, do it in a session. If your session is inproc, the dataset object will be stored in memory (you will retain some performance because there will be no serialization).

If I were you, I would analyze the code and try not to store the entire data set in any session or view - there should be a way to optimize your code.

Hope this helps.

+3
source

If you want to save the entire data set, there is always a caching method that allows you to store a huge variable with good performance. Here is an example of how you can save a variable in Cache.

Cache["CacheItem1"] = "Cached Item 1"; 

And this is how to extract the variable after:

 string cachedString; cachedString = (string)Cache["CacheItem"]; 
+2
source

Saving a dataset in a viewstate or session is not recommended, but of the two, storing it in a session is definitely better than viewstate. Since then, serialization / de-serialization has been processed on the server. Instead of sending serialized data to the client.

+1
source

I think storing in a session can help you, but you need to think about the points of view

  • How many users are using your application?
  • How big is the data set size? if it is larger, then do not store it in the session.

I suggest you take a look at your requirement, if possible, you can store in the cache, but this is the application tier. as a session Each user has his own session.

you can check links for links

+1
source

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


All Articles