Hi,
Ques What is the differences between ViewState and SessinState ?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Mar 26, 2012, 7:44 PM EDT
ViewState persist the values of controls of particular page in the client (browser) when post back operation done. When user requests another page previous page data no longer available.
SessionState persist the data of particular user in the server. This data available till user close the browser or session time completes.
Thanks
Jignesh TrivediRank #16 · 50.3K reputationPosted Mar 26, 2012, 7:54 PM EDT
hope this help.
SenthilkumarRank #387 · 6.5K reputationPosted Mar 26, 2012, 8:14 PM EDT
Viewstate:
The viewstate is used to maintain the state of the controls in the web page. It will be stored in the hidden control and it decreases the performance of the web application. It needs serialize and deserilize every time when store and retrieve happens. It can be disabled. It can be used only with in the page and will not work across the page in the application.
For example, if you fill the form and posted back into the server the value entered will be cleared. But this ViewState is powerful mechanism to maintain the state persist across the posted back.
ViewState["Test"] = "C-SharpConrer";
This can be configured in the page level, control level, web config level and machine config level.
Microsoft suggest to use the ControlState instead of ViewState
SessionState:
The SessionState is server side state mechanism in the ASP.Net and it is used to store the information. It can be shared across the pages in the application and it is per use base.
Session["Test"] = "C-SharpCorner";
There are several types of session states in sql server.
1) InProc
2) OutProc
3) Sql server
You can get more info on:
http://vinothnat.blogspot.com/2008/06/difference-between-view-state-and.html