ASP.NET State Management

Posted: December 6, 2010 in ASP.NET

A new instance of the Web page class is created each time the page is posted to the server. In traditional Web programming, this would typically mean that all information associated with the page and the controls on the page would be lost with each round trip. For example, if a user enters information into a text box, that information would be lost in the round trip from the browser or client device to the server.

To overcome this inherent limitation of traditional Web programming, ASP.NET includes several options that help you preserve data on both a per-page basis and an application-wide basis. These features are as follows:

  • View state
  • Control state – is not affected when view state is disabled by a page developer.  When developing new custom control we can extend the PageStatePersister class and override Save/Load methods, and you can use page adapters to configure your ASP.NET application to use different view state persistence mechanisms based on the type of client to which a page is served. If you need to serialize view state and control state to a string, you can use the IStateFormatter object that is accessed using the StateFormatter property. It efficiently serializes and deserializes object state information to a Base64-encoded (similar to what ViewState does) string. You can also override the StateFormatter property to supply your own object state serialization mechanism.
  • Hidden fields
  • Cookies
  • Query strings
  • Application state
  • Session state
  • Profile Properties – allow you to manage user information without requiring you to create and maintain your own database. In addition, the ASP.NET profile feature makes the user information available using a strongly typed API that you can access from anywhere in your application.

I gave little explanation about Control State, Profile Properties methods as most of the developers or small projects or sites that are not user rich may not know/use them.

View state, control state, hidden fields, cookies, and query strings all involve storing data on the client in various ways. However, application state, session state, and profile properties all store data in memory on the server. Each option has distinct advantages and disadvantages, depending on the scenario.

For more information refer …


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s