Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

response.redirect aint doing what it should 2

Status
Not open for further replies.

moley

IS-IT--Management
Mar 26, 2002
95
GB
anyone????

Have a form, on submit exec query then displays more html on same page for confirmation. have input following code when connection is live;
'if conn.errors.count > 0 THEN
'description = conn.errors(0).description
'response.redirect("error.asp?desc="& description & "; SQL=" & strUpdateTable)
'end if

when i force an error, i just get my confirmation html on same page. when i grey out this code, i see get the error. Is there any alternative to response redirect, as the page is not redirecting? The code works fine on two other forms and it def not syntax. Maybe something to do with header. any work arounds???

Ta
 
Did you write in the beginning of the page
Response.Buffer =true ?
 
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.

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 & &quot;<BR>&quot;
Loop
%>
 
Durug... this is a great explanation of buffering and redirecting... you should put it in an FAQ, as this question keeps coming up repeatedly!

 
That did the trick, ta very much.

Moley
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top