Which one more costilier View State or Session when a bulk data is stored. Why?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Depends on your point of view and usage, but generally session is cheaper all around.
For the client, session is nearly free. It only has to deal with keeping up with a session cookie (or the session id via the url if you configured for cookieless sessions). Viewstate pushes all the data to the client, in the text of the page source.
For the server, session and viewstate both have a cost. viewstate has to be serialized and deserialized and moved across the wire. Session is stored in memory (unless configured otherwise) but doesn’t have to be manipulated. So session uses more storage in memory over a longer period of time, viewstate creates temporary memory use and higher cpu hits. So it depends on how much data, how often the client is communicating with the server, and which resources you want to conserve… though in general, with bulk data, session would win hands-down in almost all practical cases.