Thursday, June 21, 2012

Differences between Session and ViewStates?



in session timeout parameter needed for session bind to this time.....and it server side.


<sessionState
    mode="[Off|InProc|StateServer|SQLServer|Custom]"
    timeout="number of minutes"............

   ....../>




view state not any timing ,,,,its Clint side,,,,

.1) Session is for per user session. View State is for a page. ie. Storing data in a session variable will last till the session ends.

Whereas storing data in View State will last only till the page is in live.


2) Session is server type storage where as View State is client side type storage.


3) Session variables are stored in a Session State ItemCollection object that is exposed through the HttpContext.Session property. ViewState variables are stored in hidden fields.

4) When using a SessionState Mode other than Inproc, the session variable type must be either a primitive type or serializable. This is because the session-variable is stored in an external data store. There is no mode for ViewState. By default, serialization of data will be taken care by the viewstate.



No comments:

Post a Comment