Also say that the page is redirected

xiaoxiao2021-03-05  52

First, Redirect and Transfer

In ASP.NET, I think that many people use response.redirect ("test.aspx") when redirects; and in the Tutor of MSDN. Now I have learned what I did when calling redirect ()? !

When calling redirect (), the server will send a message to the client's browser to tell "I want to go to another page", after receiving the message (request), immediately obey the command, return a confirmation to the server Message, request the server to locate the current page to the new page.

Server

Send request> Client

Receive information confirmation Back> Server

Request redirection> Test.aspx

It is seen that only a new page is redirected, just have a lot of things in the background, and the two Server action came back and forth. Why is it so troublesome, this is the efficiency and low network resources (when the network is slow It will be more slow, at this time, I will not hesitate to drop (^_^)) without the required information. Why not redirect actions directly on the Server side. Honored, MS offers a Server.Transfer ("Test.aspx"), all of which works in the Server side, so it is relatively, its redirect speed is much faster than before. It has two parameters, one for the redirection page, one for the Boolean value (used to specify whether to save the original page form). It only took a status information when redirection, that is, with ViewState saved information about the forward page. Therefore, it can be understood as a "illusion", which is to display on the page is a redirected page. However, the information of the original page is still in ViewState (see the source code, sometimes it will see a bunch of dense linear characters, it is it).

Can be like this to get the value of a text box in the original page in the new page:

Server.Transfer

"

Test.aspx

"

,

True

Request.form (

"

Username

"

);

//

The username here is the ID of the text box.

There is no perfect thing in the world:

1. Server.transfer (), only redirects to the website itself, cannot redirect to other websites, while redirect can, such as response.redirect

http://www.cnblogs.com ")

2. After using the second optional parameter of the Transfer, the error that "invalid viewState ..." may be reported, and the solution is used:

http://support.microsoft.com/default.aspx?id=kb;n-us;q316920

Second, TRANSFER and EXECUTE

In the ASP era, there is such a Dongdong Server.execute (), which is also used to redirect the page. I have a lot of web developers who don't use it (^ _ ^), and its role is only implemented. After the result, return to the original page, as follows:

Page 1

Server.execute ("Page 2"> Returns the result of page 2, then return to page 1, the final page is staying on page 1, not on page 2.

The above is mainly discussions on Redirect and Transfer usage and efficiency.

By Jabby

April 18, 2005 23:03:36

转载请注明原文地址:https://www.9cbs.com/read-34569.html

New Post(0)