Response.Redirect after Response.Flush

Discussion in 'ASP .Net' started by Glen Wilkin via DotNetMonster.com, Apr 15, 2005.

  1. 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?

    --
    Message posted via http://www.dotnetmonster.com
    Glen Wilkin via DotNetMonster.com, Apr 15, 2005
    #1
    1. Advertising

  2. Glen Wilkin via DotNetMonster.com, Apr 15, 2005
    #2
    1. Advertising

  3. Glen Wilkin via DotNetMonster.com

    Brad Guest

    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.


    "Glen Wilkin via DotNetMonster.com" <> wrote
    in message news:...
    > 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?
    >
    > --
    > Message posted via http://www.dotnetmonster.com
    Brad, Apr 15, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marina

    Re: Response.Flush() in code-behind

    Marina, Jul 1, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    440
    William F. Robertson, Jr.
    Jul 1, 2003
  2. =?Utf-8?B?TWFydGluIExlZQ==?=

    Calling FormsAuthentication.SignOut() after calling Response.Flush

    =?Utf-8?B?TWFydGluIExlZQ==?=, Sep 28, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    710
    =?Utf-8?B?RXRoZW0gQXp1bg==?=
    Sep 28, 2004
  3. Replies:
    5
    Views:
    549
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Jun 12, 2007
  4. Sal
    Replies:
    1
    Views:
    360
  5. Richard N.

    Response.Flush / Response.Redirect

    Richard N., Oct 18, 2003, in forum: ASP General
    Replies:
    1
    Views:
    183
    Tom B
    Oct 19, 2003
Loading...

Share This Page