Asp. NET page pass-through value

Source: Internet
Author: User
This question is last week to go to the ocean company interview of a pen question, interview when the interviewer also asked, although prepared beforehand also answer on, but fundamentally say oneself still not quite understand. Just this two days to do efficient platform evaluation system when the use of the page value, and then from the Internet to check some relevant information.

Common page values are as follows: QueryString value, Session value, the value of the cookie, application and transfer. Let's take a look at the working mechanisms, interlinkages, and pros and cons of various value-transfer methods.

QueryString Pass Value:

QueryString is also referred to as the value of the URL, is our common and relatively simple method of transmission, it by the data we need to splice into the connection address to the destination address.

Advantage: URL pass-through is simple and is supported by all browsers and is very effective for string type data transfer.

Disadvantage: The safety factor is not high, it is completely exposed to the data we need to transmit in the address bar, if not through the encryption technology, the high security of the data using URL value is a bit less sensible. Also, this approach is required for data types, generally only strings are passed, and it is not available for array and object delivery.

Session Pass Value:

Session value is sure that you will not be unfamiliar, it has some similarities with application, there are differences. It's a scoped global variable, for example: For an app site, a session can be a single user's message. Application is a global variable that has no local limits, and it can store information about the entire site, such as the amount of real-time access to the site.

Advantages: The use is relatively simple, not only can transfer data, but also can transfer objects, the size of the data is unrestricted.

Disadvantage: Storing large amounts of data in session variables consumes more server resources and data is easily lost.

Application Pass Value:

This way of passing people may listen to or use less, anyway I have not used. Connect it to the session value above and believe that we understand it better. It is valid throughout the life of the application, as with global variables, so it can be accessed on any page.

Advantage: Simple to use, consume less server resources, not only can pass the data, also can pass the object, the data quantity size is unrestricted.

Disadvantage: Being a global variable is easy to operate by mistake.

Value of cookies:

The value of the cookie is familiar to everyone, often with computers and mobile phone people may be in the cleaning up the garbage when there is a clean cookies, and when we clean up, found that some popular sites previously saved usernames and passwords need to be re-entered. This is the role of cookies, it is often used in the user's browser to store some user-related information, such as our user name password, when we log in when we chose to save the user name password, the information will be stored in cookies, the next time we log in without the need for us to input. So when we clean the garbage, we need to choose whether or not to clear this item. Cookies are similar to sessions in that they are for individual users, but they differ in nature from the fact that the session is stored on the server side and the cookies are stored on the client.

Pros: A very efficient way to save user state by using simple, all information stored on the client does not cause stress to the server.

Disadvantage: Security is not high, easy to be forged, to the user to bring a certain amount of memory garbage.

Transfer Pass Value:

Transfer is more advanced, only transfer can be regarded as the method used in object-oriented software design. Using the transfer method to direct the process from the current page to another page, which we often say redirects, the new page uses the front page of the reply stream, so this method is completely object-oriented.

Advantages: Direct server-side redirection, easy to use, reduce client requests to the server, can pass various data types of values and control values.

Disadvantage: The URL address in the client browser does not change, so it may result in some less-than-intentional scenarios on the new page. For example, the original page and the target page is not in the same virtual directory or its subdirectories, some use relative path of the picture or hyperlink will lead to wrong orientation.

The above is the content of the value of ASP, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • 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.