sams5817
sams5817

Reputation: 1037

How much data can ViewState store?

I having a viewstate to store a data query from SharePoint,

where the data might be very huge,

the reason why I wanted to store in viewstate is for later filter on the queried data.

However, I not sure whether it might caused any performance issue as there are alot of data (rows and columns), because as I know viewstate will consume client browser's memory.

so actually how much data can viewstate store?

Upvotes: 2

Views: 10473

Answers (5)

Jonathan Wood
Jonathan Wood

Reputation: 67193

Yes, it can absolutely cause performance issues because it increases the size of your page. ViewState is capable of storing much more data than you should ever store there because of performance issues.

I would explore other options such as caching, etc.

Upvotes: 6

CheckRaise
CheckRaise

Reputation: 550

Viewstate data is sent to and from the server to client on each and every postback thus causing the user to download that information every time. The more data stored in viewstate, the slower the page will load.

But to answer your question, there is not a size limit to viewstate.

Upvotes: 1

AjayR
AjayR

Reputation: 4179

When you are using ViewState it has get from the server and will cause performance issue. Also user browser may affect the performance.

while there is no published limit to the max size of a hidden field (implementation of viewstate) and most browsers allow large sizes, some proxy servers are known to limit them to 4k.

Upvotes: 0

Andrew Cooper
Andrew Cooper

Reputation: 32576

Not only will ViewState use memory in the user's browser, it will also slow performance of page loads because the browser has to send/receive all that data to/from the server each time.

Like others have said, you're much better off using the server-side session state, or a server-side cache.

Upvotes: 0

donkim
donkim

Reputation: 13137

The ViewState, if I remember correctly, is embedded in the source (look for <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="xxxxxxxx" />). Having a lot of data in the ViewState will cause your pages to POST more bytes with every request (and you'll need to do POSTs to access that ViewState). There's also the cost of decrypting that ViewState data (though I have no idea what kind of impact that might have...).

Hope this helps!

Upvotes: 0

Related Questions