Possible Duplicate:
Why do I get “Cannot redirect after HTTP headers have been sent” when I call Response.Redirect()?
Can I do something like this :
Response.Write(displaying some gif);
Response.Flush();
Thread.Sleep(6000);
Response.Write(@"<script>document.getElementById('loading').style.display='none';</script>");
Response.Buffer = true;
Response.Redirect("some URL")
Because I get this exception Cannot redirect after HTTP headers have been sent if I try.Can anyone help me out how to do this?
The cool kids might be using AJAX/JavaScript these days but if that’s more advanced than you want to get into right now, here’s an old-school way of doing something similar:
Create a “landing” page that shows the GIF and which also has in it’s
<head>tag,<meta http-equiv="refresh" content="6;url=http://yourURL/">where 6 is the number of seconds to wait before redirecting to the “real” page in theURL=part.Note that animated GIFs may stop animating between the time the Refresh kicks off and when your real page’s content arrives.