INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

HANDLE


PASSWORD
Remember Me
Forgot Password?

Come Join Us!

  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • Turn Off Ad Banners
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

E-mail*
Handle

Password
Verify P'word
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Member Feedback

"...I have learned more through this forum than I did on a two day course. Thanks to everyone for their help and other postings that I have found useful..."

Geography

Where in the world do Tek-Tips members come from?

Microsoft: Active Server Pages (ASP) FAQ

ASP 101

Response.Redirect and Response.Buffer
Posted: 14 Apr 02

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

The Buffer property tells whether to buffer (temporarily store) the output page being sent to the browser. A response is not sent to the browser until all scripts are processed, or the Flush or End methods are called. The Buffer property cannot be set or changed after the server has sent output to the browser. Therefore, you need to set the Buffer property on the first line of the ASP page. If the Buffer is set to True, then the server will buffer the output. If it is set to False, then no buffering occurs.

In ASP version 2.0 the default value is False and no buffering is done.

In ASP version 3.0 the default value is True and the server will buffer the output. However, there is a quirk concerning the default value of Response.Buffer that is dependent upon how Windows 2000 (which contains IIS 5.0 and ASP 3.0) is initially installed on your computer. If you do a clean install, the default value will be True. If the install is an upgrade, the default value will be False.

In the code example, there is no output because the loop does not finish and the Buffer will not empty until the script has finished. If the buffer was set to False, then the Response.Write would write the number to the browser every time it went through the loop.

Code:
<%
Response.Buffer = TRUE
x=0
Do
    x = x+1
    Response.Write x & "<BR>"
Loop
%>  


www.devguru.com
Copyright Copyright 1999-2002 by Infinite Software Solutions, Inc. All rights reserved.



Back to Microsoft: Active Server Pages (ASP) FAQ Index
Back to Microsoft: Active Server Pages (ASP) Forum
My FAQ Archive
Email This FAQ To A Friend

My Archive