Response概要

The Response object is an instance of the System.Web.HttpResponse class, and it represents the
web server’s response to a client request. In classic ASP, the Response object was the only way to
programmatically send HTML text to the client. Now server-side controls have nested, object-
oriented methods for rendering themselves. All you have to do is set their properties. As a result, the
Response object doesn’t play nearly as central a role.
The HttpResponse does still provide some important functionality—namely, cookie features
and the Redirect() method. The Redirect() method allows you to send the user to another page.
Here’s an example:
// You can redirect to a file in the current directory.
Response.Redirect("newpage.aspx");
// You can redirect to another website.
Response.Redirect("http://www.prosetech.com");
The Redirect() method requires a round-trip. Essentially, it sends a message to the browser that

instructs it to request a new page.

If you want to transfer the user to another web form in the same web application, you can use
a faster approach with the Server.Transfer() method. However, Server.Transfer has some quirks.
Because the redirection happens on the server side, the original URL remains in the client’s web
browser. Effectively, the browser has no way of knowing that it’s actually displaying a different page.
This limitation leads to a problem if the client refreshes or bookmarks the page. Also, Server.Transfer()
is unable to transfer execution to a non-ASP.NET page or a web page in another web application or on
another web server.
posted @ 2009-10-29 16:38  wispzone  阅读(203)  评论(0编辑  收藏  举报