Two kinds of server-side Web page redirection methods in IIS5

Source: Internet
Author: User
Tags header iis client
iis| Server | Web |iis| server
Two kinds of server-side Web page redirection methods in IIS5


There are two ways to redirect (or turn) server-side Web pages in IIS5.

One is the Server.Transfer method, the other is the Server.Execute method.

Say they are server side oriented because the steering between different pages is directly on the server side

Done, the client can only see the result, not the steering process. This is the same IIS4 we used in the past

The Response.Redirect method is different.


In the past, when we needed to move from one page to another, we generally used

The redirect method for response objects, for example, in one of our pages that requires user authentication, when the user

No landing time, go to the User landing page, the simple example code is as follows:


Content.asp

<%
If session ("islogin") = "" Then
Response.Redirect "Login.asp"
End If

' The normal content

%>


So, in fact, the Response.Redirect method is to return to the browser an HTTP header state of 302 tag Code,

HTTP 1.0 302 Object Moved
Location URL

In this case, the browser is actually requesting the server's content.asp file, and after the content.asp file has been processed

Tell the browser, you first access the Login.asp file, so the browser to the server to send a request to the Login.asp page.

So, actually, it's a turn in the corner. In this way, when the client network condition is not very good, two requests will be greatly

Reduces the application's response speed and even consumes extra bandwidth.


In particular, there are also problems when you need to pass parameters.



In IIS5, the Server.Transfer and Server.Execute methods are provided.

Both of these methods are used to complete the steering between servers, thus reducing the occupancy of the client's network bandwidth,

However, because the server side to save some of the state of program 1, it will also consume a certain amount of memory.



So what's the difference between Server.Transfer and Server.Execute?

By example, here are two files, file1.asp and file2.asp.

We're all going to file1.asp inside the file2.asp.


When using the Tansfer method:

File1.asp

<%
Response.Write "File 1 header<br>"

Server.Transfer "File2.asp"
' Here, stop executing the following statement and turn to the

Response.Write "File 1 footer<br>"

%>

File2.asp

<%
Response.Write "Ci Qin Qiang 2"
%>


All, when we execute the file1.asp file, the result we get is

File 1 Header
CI-Qin Strong

Because when a program encounters a transfer method, it stops executing the following statement and then executes the program that turns




When you use the Execute method:




File1.asp

<%
Response.Write "File 1 header<br>"

Server.Execute "File2.asp"
' To execute file2.asp here, and then continue with what remains.

Response.Write "File 1 footer<br>"

%>

File2.asp

<%
Response.Write "File 2"
%>


All, when we execute the file1.asp file, the result we get is

File 1 Header
File2
File 1 Footer

Because when the program encounters the Execute method, it executes the program that is turned on, and completes the remainder of the first page.

In fact, the Execute method is similar to subroutine invocation as we often write subroutines.

As shown in the following illustration:






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.