Methods of passing parameters in Web pages

Source: Internet
Author: User

In the Web page, the method of passing parameters is varied, mainly in the following ways:

Viewstate,querystring,session, Application,cookie,cache.

Viewstate:

Features: The view state of the various controls initiated by the service, including all property values of the control;EnableViewState can enable and disable view state; Advantage: Prevent the new page instance from being lost, and then lose the status information of the previous page;

For example, in the user login registration verification process, no need to use the code that causes the server round trip, we only need to authenticate on the client. In addition, some controls are initialized only when the page is first called, and!ispostback can be used to complete the initialization.

Querystring:

Features: Used for the transfer of parameters between pages, divided into two situations: in the foreground, you can use hyperlinks to complete, hyperlinks with "? "To separate the address of the page to be transferred to and the name of the routing parameter, with" + "stitching the string to form the last address information to access, if there are multiple parameters to pass, we can use" & "to connect. In the background, you can use Response.Redirect () to locate the page to be transmitted and the parameters to be transmitted.

Advantages: The system overhead is relatively small in the process of querystring passing parameters;

Disadvantage: It can only carry out string transfer, and the parameters passed in the new page address are shown, security performance is relatively low.

Session:

Features: The method of passing parameters in session is a more common way, first the server side to pass a certain parameter to the session, and then send the session value to the client, when the server every time the session is called, the client will be queried. Session saves memory overhead on the server side, but page callbacks increase.

Application:

Features: Application and session similar, but is stored in the server-side form, usually applied to the site's access to information, usage and the same color session. Application provides a parameter that is used by the user of the entire access server, but the parameter cannot be too large to prevent a large amount of overhead;

Disadvantage: And application is dependent on the server side, when the server restarts, the value of application is lost. When using it, try to set his properties as read-only properties, avoid thread synchronization, and multiple users to access the situation at the same time.

Cache:

Features: Compared to application, the cache has an expiration mechanism that assigns a time to a cache, and when that time is reached, the value stored in the cache is automatically invalidated. The cache also has the ability to take precedence, and the cache with a low priority can be moved out of the cache prior to the high priority level.

Cookies:

Feature: A Cookie is a small piece of textual information that accompanies the request and response between the WEB server and the client. A Cookie contains information that a Web application can read every time a user accesses a site.

Cons: Cookies are the least secure way to send data, because cookies are text stored on the client, and users can modify cookies to attack the server, so they cannot store more confidential files in a cookie. Most, we use it to store the user's personality, and login information.

The use of less, more in the project practice, under the guidance of these theories, in different situations to distinguish the pros and cons of the choice.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Methods of passing parameters in Web pages

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.