PDA

Click to See Complete Forum and Search --> : what's with response.redirect?


Nov 3rd, 2000, 01:48 PM
okay. i have this code and it's giving me this error, and the line that's causing this error is where i type

response.redirect "redir.asp"


the error message is:

Response object error 'ASP 0156 : 80004005'

Header Error

/redirect.asp, line 12

The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page
content.


and this is the source code:

<%@ Language=VBScript%>
<!--#include file="ADOvbs.inc"-->
<html>
<head>
<title>trying redirect</title>
</head>
<body>
<%
Dim varConfirm
varConfirm = Request.Form("rConfirm") 'no problem here
If varConfirm="no" Then
Response.redirect "redir.asp"
else
' code if varConfirm="yes"
end if
%>
</body>
</html>

monte96
Nov 3rd, 2000, 02:29 PM
You can't use response.redirect after the <HTML> tag has been written to the browser.

If you put it before the HTML tag, it will work fine.

Nov 3rd, 2000, 02:39 PM
i knew it had to be something simple. sorry. just self-studying with asp, see. and the book i'm using as reference put response.redirect in between the <html> tags.

Nov 4th, 2000, 06:07 PM
Actually it has to do with when the http header is sent back to the requesting client(like the error message stated) and not with the "<html>" tag. The following works perfectly because the Response.Buffer = True statement...


<%
Option Explicit
Response.Buffer = True
%>
<html>
<body background="/images/bground.gif" bgcolor="#ffffff" text="#000000" marginheight="0" topmargin="0">
test
</body>
</html>
<%
Response.Redirect "http://msdn.microsoft.com/"
%>

monte96
Nov 4th, 2000, 11:29 PM
That's true.. In his case I simply assumed he had not set the html stream to buffer so it was outputting as it was going along..