|
 |
asp_web_howto thread: response.redirect problems
Message #1 by palandor <palandor_alt@y...> on Thu, 13 Dec 2001 08:16:07 -0800 (PST)
|
|
hi all,
i'm having a problem with using response.redirect back to the same page....
on my server i have buffer asp turned off.
the first access to the page is http://academic.udayton.edu/front/search.htm
(the link to click is "other"). that goes to
http://academic.udayton.edu/front/list.asp?school=OTHER which generates dynamic
code.... i know when school is other that there will only be one department so
i am trying to have the page reload or go to
http://academic.udayton.edu/front/list.asp?deptcode=NA&school=OTHER
automatically when a user selects the "other" link.
if (school <> "OTHER") then
//list departments
do until rs1.EOF
//rs1 is the recordset from the sql database
Response.Write("<a href='"&Application("serverURL"))
Response.Write("front/list.asp?deptcode=" &
rs1.Fields(application("deptcode")).value)
Response.Write("&"&Application("school")&"=" & school & "'>")
Response.Write(rs1.Fields(application("deptname")).value&"</a> ")
Response.Write("<br> ")
rs1.MoveNext
loop
elseif Right(Request.ServerVariables("HTTP_REFERER"),10) = "search.htm" then
//autolist the people if school = OTHER
response.redirect("list.asp?deptcode=NA&school=OTHER")
end if
if i try it this way the page comes back with the error:
"Response object error 'ASP 0156 : 80004005'
Header Error
/front/list.asp, line 126
The HTTP headers are already written to the client browser. Any HTTP header
modifications must be made before writing page content."
and if i try it with response.buffer=true at the top of the page then the page
seems to be stuck calling itself and never writes out anything for obvious
reasons..... i tried using response.end but i don't fully understand how to
utilize it.
i'm doing something wrong but am not sure how to correct it. if anyone can help
i'd appreciate it a lot! this isn't a major bug but it's annoying me....
thanks
brian
__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com
Message #2 by "Ken Schaefer" <ken@a...> on Fri, 14 Dec 2001 18:35:22 +1100
|
|
www.adopenstatic.com/faq/headererror.asp
rewrite your code so that you do not send any HTML before you issue the
Response.Redirect
ie *test* for the redirect conditions *first*, then send any HTML if you are
not redirecting
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "palandor" <palandor_alt@y...>
Subject: [asp_web_howto] response.redirect problems
: hi all,
: i'm having a problem with using response.redirect back to the same
page....
: on my server i have buffer asp turned off.
: the first access to the page is
http://academic.udayton.edu/front/search.htm
: (the link to click is "other"). that goes to
: http://academic.udayton.edu/front/list.asp?school=OTHER which generates
dynamic
: code.... i know when school is other that there will only be one
department so
: i am trying to have the page reload or go to
: http://academic.udayton.edu/front/list.asp?deptcode=NA&school=OTHER
: automatically when a user selects the "other" link.
:
: if (school <> "OTHER") then
: //list departments
: do until rs1.EOF
: //rs1 is the recordset from the sql database
: Response.Write("<a href='"&Application("serverURL"))
: Response.Write("front/list.asp?deptcode=" &
: rs1.Fields(application("deptcode")).value)
: Response.Write("&"&Application("school")&"=" & school & "'>")
: Response.Write(rs1.Fields(application("deptname")).value&"</a> ")
: Response.Write("<br> ")
: rs1.MoveNext
: loop
: elseif Right(Request.ServerVariables("HTTP_REFERER"),10) = "search.htm"
then
: //autolist the people if school = OTHER
: response.redirect("list.asp?deptcode=NA&school=OTHER")
: end if
:
: if i try it this way the page comes back with the error:
: "Response object error 'ASP 0156 : 80004005'
: Header Error
: /front/list.asp, line 126
: The HTTP headers are already written to the client browser. Any HTTP
header
: modifications must be made before writing page content."
: and if i try it with response.buffer=true at the top of the page then the
page
: seems to be stuck calling itself and never writes out anything for obvious
: reasons..... i tried using response.end but i don't fully understand how
to
: utilize it.
:
: i'm doing something wrong but am not sure how to correct it. if anyone can
help
: i'd appreciate it a lot! this isn't a major bug but it's annoying me....
: thanks
: brian
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
 |