4.3.3 execute other web pages
One of the new features of ASP 3.0 and IIS 5.0 is the introduction of the programmable server-side redirection concept. This means that you can transfer the control and execution of a webpage to another webpage without using the Response. Rdedirect method on the client.
1. Client redirection problems
ASP programmers usually use the Response. Redirect statement to load a page to the webpage currently being executed. However, many people do not realize that this statement will not automatically load and execute new web pages on the server immediately. What is actually done is to add an HTTP redirection header to the output stream sent to the customer by the Web server. This header is as follows:
HTTP/1.1 302 Object Moved
Location newpage. asp
The standard HTTP status information "302 Object Moved" in this header informs the browser that the requested resource has been Moved. The Location header provides the corresponding webpage address. Of course, this address is not necessarily true. What we are doing now is to "cheat" the browser so that the browser can find the desired webpage in another location. What actually happens is that the server executes the requested webpage, but notifies the browser that the webpage required has been moved. This is why the Redirect method must be executed before any page content is sent to the browser.
When a browser receives the "302 Object Moved" message, it interrupts the current request and sends a new request to the webpage specified in the Location value. This works the same way as when a META HTTP-EQUIV tag is used in the <HEAD> segment of a web page, and the preceding HTTP header can also be written:
<META HTTP-EQUIV = "REFRESH" CONTENT = "0; URL = newpage. asp">
Therefore, redirection actually occurs on the client, not on the server. If a proxy server is in use on the connected client, a false message may be displayed. This is how to use Response. the reason why The message "The object you requested has been moved and can be found here" is often displayed on The client during Redirect. Correct Buffering can usually prevent this problem.
When using Response. Redirect in IIS 4.0 or earlier versions, you should enable the buffer at the beginning of the ASP web page, and then call Response. Clear before executing the Response. Redirect Method. Of course, in ASP 3.0, webpage buffering is enabled by default, so this is not a problem. As long as Response. Clear is used before the statement is executed, the previous output will not be sent to the customer.
2. Server redirection in ASP 3.0
In ASP 3.0 and IIS 5.0, Execute and Transfer are two new Server object methods in almost all cases to avoid client redirection. These two methods enable the control to immediately jump to another web page, which can be an ASP web page or any other resource, such as an HTTP web page, compressed file, or other types of files.
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