Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is ViewState stored?

Where is a ViewState Stored? Is it stored in Server or Client Side?

I have a huge data which should be stored for some process. I was using Session. But when moved from one page to another im not able to clear the session. So I thought of implementing ViewState. But when running with huge amount of data ViewState is throwing error?

How can I resolve this?

like image 336
smilu Avatar asked Jun 11 '12 08:06

smilu


2 Answers

Viewstate is stored on page it self in encoded form. You can't access the viewstate in client side in a direct manner. You need to know the encoding/decoding algorithms to fetch the valuable data from this viewstate in clientside code.

You can use hidden variable to store data that will be used only on that page. Hidden variables are accessible from client side and server side code.

You can use Cache or session to store datatable (large data). They will have good performance as compare to ViewState.

The Cache is always using the machine's memory, the Session uses what has been configured:

In a web farm the Session can be local (which works only if affinity is set), or remote (state server or database, or custom), but the cache is always local.

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

PS: storing a DataSet instead of a DataTable will change almost nothing.

Refer Cache Implementation

like image 65
Romil Kumar Jain Avatar answered Oct 25 '22 10:10

Romil Kumar Jain


The ViewState is not stored on either side, it's send back and forth between the server and the browser on every request and response, so it's not a good idea to put a huge amount of data in ViewState.

like image 20
Guffa Avatar answered Oct 25 '22 11:10

Guffa