State management is the process by which you maintain state and page information over multiple requests for the same or different pages. As is true for any HTTP-based technology, Web Forms pages are stateless, which means that they do not automatically indicate whether the requests in a sequence are all from the same client or even whether a single browser instance is still actively viewing a page or site. Furthermore, pages are destroyed and re-created with each round trip to the server; therefore, page information will not exist beyond the life cycle of a single page.

ASP.NET provides multiple ways to maintain state between server round trips. Which of these options you choose depends heavily upon your application, and it should be based on the following criteria:

 

  • 1. How much information do you need to store?

  • 2. Does the client accept persistent or in-memory cookies?

  • 3. Do you want to store the information on the client or on the server?

  • 4. Is the information sensitive?

  • 5. What performance and bandwidth criteria do you have for your application?

  • 6. What are the capabilities of the browsers and devices that you are targeting?

  • 7. Do you need to store information per user?

  • 8. How long do you need to store the information?

  • 9. Do you have a Web farm (multiple servers), a Web garden (multiple processes on one machine), or a single process that serves the application?

Client-Side State Management Options

Storing page information using client-side options doesn't use server resources. These options typically have minimal security but fast server performance because the demand on server resources is modest. However, because you must send information to the client for it to be stored, there is a practical limit on how much information you can store this way.

The following are the client-side state management options that ASP.NET supports:

  • View state

  • Control state

  • Hidden fields

  • Cookies

  • Query strings

Server-Side State Management Options

Server-side options for storing page information typically have higher security than client-side options, but they can use more Web server resources, which can lead to scalability issues when the size of the information store is large. ASP.NET provides several options to implement server-side state management.

The following are the server-side state management options that ASP.NET supports:

  • Application state

  • Session state

  • Profile properties

  • Database support

posted on 2011-08-17 11:56  lochker  阅读(212)  评论(0编辑  收藏  举报