We help IT Professionals succeed at work.

Response.Redirect Problem

rogueripper
rogueripper asked
on
Medium Priority
871 Views
Last Modified: 2012-06-22
Hi there

I am running the following from a Windows NT 4.0 workstation on IE 6.0

This is my options.asp page's content:


<%@ Language=VBScript %>
<!--#include file="iiSecurity.asp"-->
<!-- #include file = "common/d5wfl1a.asp" -->

<%

dim Redirector

     if Session("FullScreen") = True Then
          Redirector = "fullscreen.asp"
          Session("windowstate") = "Show Tree"
     else
          Redirector = "main.asp"
          Session("windowstate") = "Full Screen"
     end if

     Response.Redirect Redirector

%>



This is the error I receive when I run it in IE



Response object error 'ASP 0156 : 80004005'

Header Error

/fedpacs/options.asp, line 17

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




How do I solve this?

Thanx! :o)


Comment
Watch Question

First line of code (before those include files) needs to be a quick Response.Buffer = True. Put this at the very top of your page, and you'll be OK!!
Commented:
Response.Redirect() works smoothly when no data has been sent to the client browser. You've sent data to the client when:

1) You've called or executed any Response methods in your include ASPs.
2) You have HTML tags outside the ASP <%...%> delimiters placed in code above/before the call to Response.Redirect.

So if you have:

<%
Response.Write "Boo!"
'... more codes
Response.Redirect "tothisURL"
%>

Or:

<html>
<%
Response.Redirect "tothisURL"
%>

You get the error.

Check you include files. Or move your line(s) of code calling Response.Redirect above the include files.

Commented:
roqueripper,

Use Response.Buffer = 0 in the top page, exp:

<%@ Language=VBScript %>
<%Response.Buffer = 0%>
<!--#include file="iiSecurity.asp"-->
<!-- #include file = "common/d5wfl1a.asp" -->

<%

dim Redirector

    if Session("FullScreen") = True Then
         Redirector = "fullscreen.asp"
         Session("windowstate") = "Show Tree"
    else
         Redirector = "main.asp"
         Session("windowstate") = "Full Screen"
    end if

    Response.Redirect Redirector

%>

Regards,
Wee Siong

Commented:
Try replacing :

Response.Redirect Redirector

With:

Response.Clear
Response.Write "<script>parent.location='./../../" & Redirector & "'</script>")

Commented:
<!--#include file="iiSecurity.asp"-->
<!-- #include file = "common/d5wfl1a.asp" -->

What are these? If they have ANY HTML code, or any response.write, that's what the problem is. You CANNOT have any output to the page, or generate any HTML output before the redirect.

And I'm betting that those are standard headers -- and HTML. If so, take them out.

Also, this
Response.Redirect Redirector
is referring to your FUNCTION -- that's not what you want. Redirect should take you to another PAGE, a completely different location. NOT run a function on the existing page. Doesn't work that way.

Commented:
i have seen lots of people have somehting in teh security.asp file that outputs a comment "<-- Authenticated -->" and that will fail.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.