Response.Redirect after Response.Flush

  • Thread starter Glen Wilkin via DotNetMonster.com
  • Start date
G

Glen Wilkin via DotNetMonster.com

Is there a way I can call Response.Redirect after I've done a
Response.Flush?
I send some html to load an animated gif that plays whilst my page loads,
it has some extensive database calls to process. However, when I try to
redirect to my error handling page, if there is an error, I get a 'Cannot
redirect after HTTP headers have been sent' error.
I've got round the problem by using a javascript function in the body
onload event that checks a hidden field whose value is set when an error
ocuurs, but this does seem very elegant.
Any ideas?
 
G

Glen Wilkin via DotNetMonster.com

Sorry I meant to say that the javascript fix is NOT very elegant.
 
B

Brad

Just as the error states, you cannot do a redirect once headers, or any
parge of the page, has been sent to the client. An alternative to what you
are doing would be to just write client side script directly into the
response.
i.e.
Response.Write("<script
language=javascript>window.navigate('mynewpage.aspx);</script>")
Response.End

The above script is not a function so it will execute inline immediately
when sent to the browser and direct client to another page. Think of it as
an immediate client side redirect.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top