Abstract: Dynamic web design based on web will inevitably involve data transfer between pages. This article discusses the data transfer methods commonly used between web pages in asp design, and analyzes the usage methods, usage occasions, advantages and disadvantages of various data transfer methods, They are all key to consider when choosing the data transmission method during the design stage.
Keywords data transfer variable browser-side web page
When using dynamic web page technology to create ASP applications, you usually have at least two or more web pages. At this time, you have to consider the processing of transferring data between multiple web pages. Each page of an ASP application is similar to the form form of a Windows application. Data transfer between forms of a Windows application can be achieved by defining global variables and other methods. There are many different ways to transfer data between web pages, and the appropriate selection of data transfer methods between web pages plays a decisive role in the rationality and security of system design and operation.
1. url method
The URL method is the most basic method to transfer data between webs. It is simple to operate and can easily transfer data between different web pages, but its security is relatively poor. The data to be transferred is appended to the web page address (url) and passed. For example: http://www.cstvu.com/testweb?username=liming, where? The string that follows is the passed data. The variable name is before =, and the value is after =. You can use the request object to obtain the passed data. Such as: request(username). In this method, the data content is displayed in the URL bar during the data transmission process, and the user can see the submitted content.
2. form method
By creating a form interaction area on the web page, the user inputs data on the browser side and then submits it to the server through the form. The corresponding data can be received in the page that accepts the form data after submission, that is, the request can be used in the action page of the form. Object to receive the passed data.
like:
Send page:
<form name=formtest action=targetweb.asp>
<input name=testtext type=textvalue=>
<input name=testbutton type =submitvalue =submit>
</form>
Receiving page: request(testtext)
Use the text box of the form page to receive user data input, and use request in the target web page to receive the data after submitting it through the submit button.
3. Cookie method
Cookies are small files written by the web server on the browser side when browsing a page. Cookies are stored on the local disk of the browser, not on the server side. You can write cookies when sending data, and read cookies when receiving to complete the transfer of data between web pages.
like:
Send page: response.cookies(cookiename)(username)=liming
Receiving page: request.cookie(cookiename)(username)
Assign a value to the cookie variable in the sending page, and the value of the cookie variable in the receiving page is the transferred data.
4. application object
The application object is used to record information about the entire website. It records variables shared by different browsers. No matter how many viewers access the web page at the same time, only one application object instance will be generated. Users can achieve data transfer between web pages by defining application-wide shared variables. The definition method is: application (variable name) = numerical value
For example: application(usrname)=liming
The variables defined by the application object are visible to all browsers, so their usage is global data transfer shared by all browsers.
5. session object
The session object is used to record variables on the browser side. It is a variable dedicated to individual browsers. A session object will be automatically generated for each browser access. This object provides a storage place to store only the information of the visitor. Variables and objects available to web pages opened during the activity of a session. This can be used to pass data across the web that is specific to a single browser. Its definition method: session (variable name) = numerical value
For example: session(usename)=liming
The variables defined by the session object are only dedicated variables on the browser side, so they are suitable for transferring web page data between local sessions.
6. Conclusion
The above introduces the common methods of data transfer between web pages, each with its own merits. Among them, the URL method and the form method are simple to implement, and can realize simple data transfer between web pages. They are generally of string type. They are characterized by poor security, and data transfer between two pages must be continuously accessed. Cookies can only store string type data. If you want to store more complex data types, you must first convert them to string type. The operations of application objects and session objects are relatively complicated. Web pages with very large page views should be used in moderation and should be cleared after use. Otherwise, heavy use may cause the server to paralyze. The session variable is highly secure and can pass dedicated browser data. The specific application determines the choice of data transmission method, and the selection of reasonable data transmission method is a key consideration in the design of web pages.