Pages

Sunday, February 24, 2008

State Management in .Net

Web form pages are HTTP-Based, they are stateless, which means they don’t know whether the requests are all from the same client, and pages are destroyed and recreated with each round trip to the server, therefore information will be lost, therefore state management is really an issue in developing web applications

We could easily solve these problems in ASP with cookie, query string, application, session and so on. Now in ASP.NET, we still can use these functions, but they are richer and more powerful, so let’s dive into it.

Mainly there are two different ways to manage web page’s state:
1) Client-side
2) Server-side

1.Client-side state management :
--> Cookies
You need to store small amounts of information on the client and security is not an issue.

--> View state
You need to store small amounts of information for a page that will post back to itself. Use of the ViewState property does supply semi-secure functionality.

--> Hidden fields
You need to store small amounts of information for a page that will post back to itself or another page, and security is not an issue.

--> Query string
You are transferring small amounts of information from one page to another and security is not an issue.

2. Server-side state management:

--> Application state object
You are storing infrequently changed, application-scope information that is used by many users, and security is not an issue. Do not store large quantities of information in an application state object.

--> Session state object
You are storing short-lived information that is specific to an individual session, and security is an issue. Do not store large quantities of information in a session state object. Be aware that a session state object will be created and maintained for the lifetime of every session in your application. In applications hosting many users, this can occupy significant server resources and affect scalability.

--> Database support
You are storing large amounts of information, managing transactions, or the information must survive application and session restarts. Data mining is a concern, and security is an issue.

Keep watching for information around state Management...

1 comment:

Anonymous said...

Very valuable information, the way you structured your blog is too gud.