Menu ▼



Posted By :
avatarmrkraju
Total Views : 477

Difference between SessionState and ViewState in asp.net

SessionState

  • If you want to store infromation that you want to access on different pages then you can use SessionState.
  • SessionState is saved on the server.
  • Data stored in the SesionState will be cleared when the session expired(usually after 20min of inactivity when using session inproc).
  • SesionState is used to save the user specific data like UserID, User Role, etc.


ViewState

  • If you want to store information that you want to access only with in the page(same page) then you can use ViewState.
  • ViewState is saved in the page.
  • Data stored in the ViewState will send back to the server when postback action performed (no expiration).
  • ViewState is used primarily by Server controls to retain state only on pages that post data back to themselves. And when you want to save the pagelevel data you can use ViewState.






comments powered by Disqus


Search dotnetlearners.com