State management is the process by which you maintain state and page information for multiple requests on the same page or on different pages. Like all HTTP-based technologies, WEB forms pages are stateless, meaning they do not automatically indicate whether the requests in the sequence are all from the same client, or whether a single browser instance has been viewing the page or site. In addition, each round trip to the server destroys and recreate the page, so if the life cycle of a single page is exceeded, the page information does not exist.
ASP.net provides a variety of ways to maintain state between server round trips. The choice of these state management options depends primarily on your application and should be based on the following criteria:
How much information is needed to store?
Does the client accept persistent or in-memory cookies?
Do you want to store the information on the client or on the server?
Is the information sensitive information?
What performance and bandwidth conditions are you setting for your application?
What capabilities does the target browser and device have?
Do you need to store information based on the user?
How long does the information need to be stored?
Do you use a Web farm (multiple servers), a Web garden (multiple processes on one computer), or a single process to run your application?
Client state Management
View state
The Web Forms page provides the ViewState property as a built-in structure that automatically preserves values between multiple requests on the same page. View state is maintained as a hidden field in the page.
You can use view state to store your own page-specific values across a round trip when the page is sent back to itself. For example, if your application is maintaining user-specific information (that is, the information is used on a page but is not part of any control), you can store that information using view state.
Advantages of using view state
No server Resource view state is required to be included in the structure within the page code.
Implementing simple view state does not require any custom programming. The maintenance of state data is enabled for the control by default.
Enhanced security features the values in view state are hashed and compressed, and are encoded for the Unicode implementation, which is more secure than using hidden fields.
Disadvantages of using view state
Performance considerations because view state is stored in the page itself, if you store large values, users may slow down when they display the page and send the page. Especially for mobile devices, the bandwidth is usually limited.
Device limits mobile devices may not have enough memory capacity to store large amounts of view-state data.
The potential security risk view state is stored in one or more hidden fields on the page. Although view state stores data in hashing format, it can be tampered with. If you view the page output source directly, you can see the information in the hidden field, which causes potential security problems.