Where is ViewState stored?

Where is ViewState stored? Is it stored on the server or on the client side?

I have huge data that needs to be stored for some process. I used the session. But when switching from one page to another, they were not able to clear the session. So I was thinking about implementing ViewState. But when working with a huge amount of data ViewState throws an error?

How can i solve this?

+6
source share
5 answers

Viewstate is stored on its own page in encoded form. You cannot directly access a client-side view. You need to know the encoding / decoding algorithms in order to extract valuable data from this viewport in client code.

You can use a hidden variable to store data that will be used only on this page. Hidden variables are available on the client side and on the server side.

You can use a cache or session to store data (big data). They will have good performance compared to ViewState.

The cache always uses the device’s memory, the session uses the configured value:

In a web farm, a session can be local (which works only if there is a binding) or remote (state server or database or user), but the cache is always local.

So, storing a DataTable in a cache will consume memory, but will not use serialization.

PS: saving a DataSet instead of a DataTable will not change much.

Refer to cache implementation

+8
source

The ViewState is not saved on both sides, it sends back and forth between the server and the browser with each request and response, so it is not recommended to place a huge amount of data in the ViewState.

+7
source

ViewState is stored where you specify it. By default, this is in a hidden field on the page sent to the client.

ASP.NET can also store the ViewState inside the session , i.e. on the server, if you tell it.

+3
source

Saving a large amount of data in slow motion viewing of your site. Use the query string to retrieve a new copy from the database on each page, rather than saving the whole information from the previous page.

+1
source

View government information repositories in hidden fields. Information moves between the server and the client in these hidden fields.

To control asp.net .. by default .net implements the view state for its entire control, so the value of the text field is not lost when we click the button on this page.

0
source

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


All Articles