Thursday, August 24

ViewState, SessionState and Application State 101

Here are a few things I learnt about  ViewState, SessionState and ApplicationState today.

ViewState property is used to save data in a hidden field on a page. Because, ViewState stores data on a page, it is limited to items that can be serialized. Complex items have to converted to & from strings.

ViewState info from one webform isunreadable to other webforms
Property
        ICollection ViewState.Values
Method:
       ViewState.Add(string key, object value)

One should limit the access points to Application & Session State and basically create page level variables to store data from these and write back to them at the end.

Maintaining Session state affects performance.

Application state variables are available throughout a current process but not accross processes. If an app is scaled to multiple servers or multiple processors within a server, each process has its own application state.

In Visual C#, be sure to test whether the state variable is null or not before using methods like ToString() on it.

Mechanisms for communication between webforms
  1. Context.Handler object (Use this object to retrieve public members of one webform's class from a subsequently displayed web form.
  2. Query strings
  3. Cookies
  4. ViewState
  5. Session state
  6. Application State


Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]