asp.net state management: ViewState and cookies

Source: Internet
Author: User
Tags socket

Brief introduction

The HTTP protocol is stateless. Connections from the client to the server can be closed after each request. However, it is generally necessary to transfer some client information from one page to another.

The root cause of statelessness is that the browser and the server use socket communication, and the server closes the current socket connection after returning the request result to the browser. And the server destroys the Page object after the page has finished processing.

The reason for application is that the HTTP protocol is followed by the communication between the browser and the server.

The HTTP protocol is stateless and will not remember the last and the page "what happened." The server does not remember what was given to the browser last time.

The impact on the site: if the user entered some information, when the jump to the next page, data loss, no longer get those data.

If you want to know the last state information, we have to record this state information somewhere:

A. Server-side

B. Browser side (client)

C. Form elements-such as: Hidden domain <input type= "hidden"/> (HTTP message)

In the various ways in which the state is saved, the main difference is whether the state is stored on the client or server, and the following table lists the various state management techniques and when the status remains valid.

First of all, the state management of the five basic concepts together to facilitate the comparison of memory.

There is a more granular solution on the network, as shown in the following illustration:

Client's state retention scheme: ViewState, hidden fields, Cookies, control state, URL query parameters

Server-side State retention Scenarios: session (Sessions), Application, Caching (cache), database (databases)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.