Results 1 to 5 of 5

Thread: what's with response.redirect?

  1. #1
    Guest
    okay. i have this code and it's giving me this error, and the line that's causing this error is where i type
    Code:
    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:
    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>

  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    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.
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  3. #3
    Guest

    Smile thanks, dude

    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.

  4. #4
    Guest
    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...

    Code:
    <%
    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/"
    %>

  5. #5
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    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..
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width