1. Get (that is, explicit delivery using querystring)
Method: Follow the URL followed by the parameter.
Features: Simple and convenient.
Disadvantage: The string length is 255 characters long, and the data is leaked in the URL.
Applicable data: Simple, small, critical data.
Applicable scope: Pass to oneself, pass to another target page, commonly used to pass data between 2 pages.
Usage: For example: URL after add? Userid= ..., jump to the target page, the target page can be request.querystring["Inputtext" on the server to get its specified parameter value.
2. Post
Way: The general way. Use form to submit.
Features: The most commonly used method. A common technique is to put hidden data in a hidden field that is submitted by form.
Applicable data: Large amount of data, including file upload.
Scope of application: Same Get method
Usage: Submit after client Form specifies an action target, use Server.Transfer (URL) in the ASP.net server, and get it in request.form["Formfieldid" at the server end.
3. Properties of Page objects
Way: asp.net peculiar way. Use HttpContext to get information about the page you are requesting.
Features: You can store objects directly.
Disadvantage: Note that the type of cast is correct.
Applicable data: various data.
Scope of application: Pass complex data between pages.
Usage: Gets Context.Handler to convert it to an instance of the page that sent the request, and then easily access the fields, even properties, in its form. The context refers to the HttpContext object, handler is its property, Context.Handler meaning can be understood as creating an instance variable of the source page class, and when this instance is obtained, it can directly access the properties and public methods.
4. Cookies
Way: The classic method of putting data in the client.
Disadvantages: Low security, limited by client settings, one site with only 20 cookies per capacity of 4096 bytes.
Validity period: Custom or cleared by user
Applicable data: User's session data (typically user name, user's personalization information, etc.)
Applicable scope: Single user, entire site all pages
Usage: Reference Request.Cookies (read information), Response.Cookies (write information), or create a cookie object directly with HttpCookieCollection.
5. Session
How to: Store user data on the server side.
Features: ASP.net can set the storage mode, location and SessionID of the session to rely on cookies.
You can store objects directly.
Disadvantage: There is a potential failure in the ASP.net
Validity period: User activity time + custom delay.
Applicable data: User-specific information.
Applicable scope: Single user, entire site all pages.
Usage: session["collectionname"] = Value/object;
6. Cache
How to: Store user data in a server-side data cache.
Features: can greatly improve efficiency. You can store objects directly.
Disadvantage: Data update is not timely.
Validity period: Application life cycle or customization.
Applicable data: All pages, all users can share the data.
Usage: cache["collectionname"] = Value|object;
7. Appliction
How to: Store data here, equivalent to global variables.
Features: You can store objects directly. Shared data across the site.
Validity period: Application lifecycle.
Applicable data: All pages, data shared by all users.
Usage: appliction["collectionname"] = Value|object;
8. ViewState
Mode: asp.net-specific mechanism used to restore page state.
Features: Serializes page controls and their stored data into hidden fields with name _viewstate.
Disadvantage: There is less security in HTML. Encryption and authentication can be set, but the amount of data increases and the efficiency is affected.
Applicable data: Page postback need to save the data, the data will affect the efficiency of the page sent.
Applicable scope: The page own data preservation.
Usage: viewstate["collectionname"] = value;
9. Static
How to: Save data in a static variable.
Characteristics: It is beneficial to improve efficiency.
Disadvantage: If used poorly will cause the user or page data disorder, causing great hidden trouble. It is recommended that you assign values only once, and that you absolutely prohibit changing this value for individual users.
Applicable data: Data shared by all users.
Applicable scope: All page instances of this class.
Usage: Declare a static variable in class.
Finishing:
The page itself holds data available with viewstate,static variables.
Transfer data between pages commonly used Get,post,httpcontext, of course, can be modified for their own data preservation.
Single user of all page data sharing common Session,cookie, of course, can also be applied in both cases.
The data share of the entire application (pages used by all users) is commonly appliction,cache,static variable.
Summarize:
Of course, flexible applications can be adapted to solve the problem, but to choose the right, common to abuse get and session.
It is recommended that you specify the collection when you use the request, such as the arguments from the Get method from the QueryString collection, the post from form, and the cookie from the cookies. Although the use of request[] set, several of these can be taken, but the performance of the waste, was directly in the Form set, but traversed the querystring,form,cookies and other collections to take out.
PS: In the computer world, the one side of the service is called the server, and the other side of the receiving service is called the client.