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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

redirecting? 1

Status
Not open for further replies.

taval

Programmer
Jul 19, 2000
192
GB
currently I have an asp script that has the snippet of code:<br><br>-----------------------------------<br>strAlt = Request.Form(&quot;Customers&quot;)<br><br>Select Case strAlt<br><br> Case &quot;List Customers&quot;<br> Response.redirect &quot;dpcustomer.asp&quot;<br> End select<br>------------------------------------<br><br>when I run the script I get the error message:<br><br>----------------------------------<br><br>Response object error 'ASP 0156 : 80004005' <br><br>Header Error <br><br>/webdb.asp, line 51 <br><br>The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content. <br><br>--------------------------------------------<br><br>this is the error message concerned with the code shown.<br>Is there any way I can go to another page in an asp script?<br>I think response redirect only works when placed before and &lt;html&gt; and &lt;body&gt; tags.<br><br><br>
 
You need to enable buffering in order to use Response.Redirect, Response.Flush, and Response.Clear.&nbsp;&nbsp;To enable buffering, add<br><br>Response.Buffer = True<br><br>to the top of your web page.&nbsp;&nbsp;This directive must be sent to the web server *prior* to any HTML (HTTP Headers...which is the error message you are receiving), so it will need to be very near the top. <p>Monte Kalisch<br><a href=mailto:montek@montekcs.com>montek@montekcs.com</a><br><a href= > </a><br>Brainbench MVP for ASP<br>
 
I understand what you've said but my page has content on it, so how do I jump to another asp page. The decision to jump to another page has to be made in the between the &lt;html&gt; tags (from a CASE statemenmt as above). Is there an ASP/JavaScript way I can do this?<br><br>Thankx
 
if you try to redirect after sending stuff to the browser, you will generate an error, you must redirect before sending any data to the screen. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
 
Taval, in order to the response.redirect directive, you have to enable buffering at the top of your page.&nbsp;&nbsp;You cannot even *use* response.redirect unless you do this.&nbsp;&nbsp;Here is a sample ASP/HTML page:<br><FONT FACE=monospace><br>&lt;% Response.Buffer = true %&gt;<br>&lt;html&gt;<br>&nbsp;&nbsp;&nbsp;&lt;title&gt;blah blah&lt;/title&gt;<br>&lt;/html&gt;<br>&lt;body&gt;<br>&lt;h1&gt;Hello World&lt;/h1&gt;<br>&lt;%<br><br>&nbsp;&nbsp;&nbsp;if Request(&quot;Customers&quot;) = &quot;List Customers&quot; then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response.redirect &quot;dpcustomer.asp&quot;<br>&nbsp;&nbsp;&nbsp;end if<br>%&gt;<br><br>&lt;h2&gt;More HTML&lt;/h2&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</font> <p>Monte Kalisch<br><a href=mailto:montek@montekcs.com>montek@montekcs.com</a><br><a href= MVP for ASP</a><br>
 
You can make any queries to databases, request any server variables or do any asp stuff *before* sending html code to the client. Therefore there is really no need to send stuff to the browser before redirecting. If you still have to redirect you could use the meta refresh-tag which looks like:<br><br>&lt;META HTTP-EQUIV=&quot;REFRESH&quot; CONTENT=&quot;2; URL=<A HREF=" TARGET="_new"> this case the client jumps to the page yourpage.asp after 2 seconds.<br>&nbsp;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top