Response Object
All Collections
All Methods
All Objects
All Properties
METHOD: Response.Redirect
Response.
Redirect
(URL)
The
Redirect
method stops processing the current script and attempts to connect the client to a different URL. This is accomplished by adding an HTTP redirection header to the output stream that is being sent from the server to the client. Unfortunately, if page content has already been sent to the client and if a proxy server lies between the server and the client, an error message can be generated. Therefore it is advisable to set
Response.Buffer
to true and to call
Response.Clear
just before calling
Redirect
.
Note in ASP 2.0, the buffering default setting is false and in ASP 3.0, the buffering default setting is true.
There is one mandatory argument.
URL
The
URL
argument is the Uniform Resource Locator (URL) that the browser is redirected to.
Code:
--------------File1.asp---------------
<% Response.Buffer = true %>
<HTML>
<BODY>
<%
Response.Write "This is File1.asp and switching to File2.asp"
Response.Clear
Response.Redirect "File2.asp"
%>
</BODY>
</HTML>
--------------File2.asp-----------------
<HTML>
<BODY>
<%
Response.Write "This is File2.asp"
%>
</BODY>
</HTML>
Output:
File1 is written and then the browser will load File2:
------------File1.asp------------------
This is File1.asp and switching to File2.asp
------------File2.asp-------------------
This is File2.asp
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information