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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
SenthilkumarPosted Mar 27, 2012, 12:14 AM
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
Jignesh TrivediPosted Mar 26, 2012, 11:54 PM
hope this help.
Satyapriya NayakPosted Mar 26, 2012, 11:44 PM
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