Home  >  Article  >  Backend Development  >  ASP.NET page passing value

ASP.NET page passing value

黄舟
黄舟Original
2017-02-23 10:07:321236browse

This question was a written test question for an interview with Ocean Shipping Company last week. The interviewer also asked it during the interview. Although I was prepared in advance and answered it at the time, fundamentally speaking I still didn’t quite understand it. . Just in the past two days, when I was working on an efficient platform evaluation system, I used page value transfer, so I checked some relevant information from the Internet.

Commonly used page values ​​are as follows: QueryString value, Session value, Cookies value, Application and Transfer value. Let's take a look at the working mechanisms, interrelationships, advantages and disadvantages of various value transfer methods.

QueryString value transfer:

QueryString value transfer is also called URL value transfer, which is commonly used and relatively simple. In value mode, it transmits the data we need to transmit to the target address by splicing it into the connection address.

Advantages: URL value transfer operation is simple and supported by all browsers. It is very effective for string type data transmission.

Disadvantages: The security factor is not high. It completely exposes the data we need to transmit in the address bar. If encryption technology is not used, it is difficult to use URL value transmission for high-security data. Some are not irrational. Moreover, this method has requirements for the data type. Generally, only strings can be passed. This method cannot be used for the transfer of arrays and objects.

Session value transfer:

I believe everyone will be familiar with Session value transfer. It has some similarities and differences with Application. . It is a global variable with scope. For example: for an application website, Session can be the information of a single user. Application is a global variable with no local restrictions. It can store information about the entire website, such as the real-time visits to the website.

Advantages: It is relatively simple to use. It can not only transfer data, but also objects. The amount of data is not limited.

Disadvantages: Storing a large amount of data in Session variables consumes more server resources and the data is easily lost.

Application value transfer:

You may have heard of this value transfer method or rarely used it, but I have never used it anyway. I believe we can understand it much better if we link it with the above Session value transfer. It is valid throughout the life cycle of the application, just like global variables, so it can be accessed from any page.

Advantages: Simple to use, consumes less server resources, can not only transfer data, but also objects, and the amount of data is not limited.

Disadvantages: As a global variable, it is easy to be misused.

Cookies by value:

We are all familiar with Cookies by value. People who often use computers and mobile phones may be cleaning up garbage. At some point, we discovered that one of the items was to clear cookies. After we cleared them, we found that previously saved usernames and passwords for some commonly used websites needed to be re-entered. This is the role of Cookies. They are often used to store some user-related information on the user's browser, such as our username and password. When we log in and choose to save the username and password, the information will be stored in Cookies. We don’t need to enter manually the next time we log in. So when we clean up garbage, we have to choose whether to clear this item according to our needs. Cookies and Sessions also have some similarities, that is, they are both targeted at a single user, but their essential difference is that Sessions are stored on the server side, while Cookies are stored on the client side.

Advantages: Simple to use, a very effective way to save user status. All information is stored on the client without putting pressure on the server.

Disadvantages: Low security, easy to be forged, and bringing a certain amount of memory garbage to users.

Transfer value:

Transfer value is relatively advanced, and only Transfer can be regarded as a method used in object-oriented software design. Use the Transfer method to guide the process from the current page to another page, which is what we often call redirection. The new page uses the response flow of the previous page, so this method is completely object-oriented.

Advantages: Redirect directly on the server side, simple and convenient to use, reducing client requests to the server, and can pass values ​​of various data types and control values.

Disadvantages: The URL address in the client browser will not change, so some unexpected situations may occur on the new page. For example, if the original page and the target page are not in the same virtual directory or its subdirectory, some pictures or hyperlinks using relative paths will cause wrong orientation.

The above is the content of the value passed in the ASP.NET page. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn