Two server-side web page redirection methods in IIS

  
                  In IIS5, there are two methods for server-side web page redirection (or steering), one is the Server.Transfer method, and the other is the Server.Execute method. They are said to be server-side redirects because the steering between the different pages is done directly on the server side, and the client can only see the results, not the process of turning. This is different from the Response.Redirect method we used in IIS4.
Previously, when we needed to move from one page to another, we generally used the Redirect method of the Response object. For example, on one of our pages that requires user authentication, when the user is not logged in, Go to the user login page, the simple example code is as follows:
content.asp

<%
If Session("isLogin")="" Then
Response.Redirect "Login.asp"< BR>End If

'Normal content

%>


So, in fact, the Response.Redirect method returns an Http Header status to the browser. 302 tag code,

HTTP 1.0 302 Object Moved
Location URL

This is actually the browser requesting the server's content.asp file, the content.asp file is processed after processing Browser, you first access the login.asp file, so the browser sends a request to the login.asp page to the server. So, actually, it turned a corner. In this way, when the client network is not in good condition, the two requests will greatly reduce the response speed of the application and even occupy the excess bandwidth. In particular, there are some problems when you need to pass parameters.


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

The two methods are all done between the servers, so the network bandwidth of the client can be reduced, but because the server side saves some state of the program 1, it also consumes a certain amount of memory.

//This article comes from the computer software and hardware application network www.45it.com reproduced please specify
So what is the difference between Server.Transfer and Server.Execute?

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

We are all going to file2.asp inside file1.asp


When using the Tansfer method:

file1.asp

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

Server.Transfer "file2.asp"
' stops here and executes the following statement, turning to

Response.Write "File 1 Footer<br>"

%>

file2.asp

<%
Response.Write "小雨在线"
%>


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

File 1 Header
小雨在线

Because, when the program encounters the Transfer method, it will stop executing the following statement, and then execute the program that turns to
>


When using the Execute method:

file1.asp

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

Server.Execute "file2.asp"
'Execute file2.asp here, continue to execute the rest after completion

Response.Write "File 1 Footer<br>"

%>

file2.asp

<%
Re sponse.Write "File 2"
%>


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

File 1 Header
File2
File 1 Footer

Because, when the program encounters the Execute method, it will execute the redirected program, and then continue to execute the rest of the first page.

In fact, the Execute method is just like the subroutine we often write, similar to the subroutine call.

as shown below:



Copyright © Windows knowledge All Rights Reserved