Hi
I want to know difference between sessionstate and viewstate in .NET ? Please tell me anyone sessionstate and viewstate with an examples ?
Thanks
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.
Satyapriya NayakPosted Apr 11, 2012, 10:55 PM
SessionState and ViewState are used to store data value.
View State:
1.View state is maintained in page level only.
2.View state of one page is not visible in another page.
3.View state information stored in client only.
4.View state persist the values of particular page in the client (browser) when post back operation done.
5.View state used to persist page-instance-specific data.
Session State:
1.Session state is maintained in session level.
2.Session state value is available in all pages within a user session.
3.Session state information stored in server.
4.Session state persist the data of particular user in the server. This data available till user close the browser or session time completes.
5.Session state used to persist the user-specific data on the server side.
Thanks
SenthilkumarPosted Apr 11, 2012, 10:27 PM
The view state is client side state mechanism
But the session state is server side mechanism.
The view state is used to maintain the data and state of the control.
But the session is used to maintain the data.
The view state is stored on the hidden control in the client side.
But the session state is stored either one in the processor memory, state or sql server.
The view state serialize and deserilize the data while storing and retreieving, it is posted on the server and render again to maintain the state. It can live upto only the scope of the page. It can't be used across the pages.
The session state can maintain across the pages. The data is persist in the memory and if it is inProc then iis restart will lost the data.
The Session has the events in the global.ascx like Session_Start and Session_End. It will maintain for the every user.
But the view state do not have any events in the global event file.