Microsoft Dot Net Master

Microsoft Dot Net Master
Microsoft Dot Net Master

Sunday, February 17, 2013

Difference between Asp.net SessionState and ViewState in C#, VB.NET


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. (Read more)


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. (Read more)   

Usage
  1.  If you want to access the information on different web pages, you can use SessionState
  2. If you want to access from the same page, then you can use Viewstate

 Security
  1.  Session state provides more security when compared with view state as the data value is stored in server side

No comments:

Post a Comment