Will Response.Redirect() stop a thread?

Discussion in 'ASP .Net' started by Mark Huebner, Jul 2, 2006.

  1. Mark Huebner

    Mark Huebner Guest

    I have an aspx web page with the following C# code in the page load event.
    Can somebody tell me if the Response.Redirect() will cause my tLoadDNN
    thread to stop executing before it is finished? tLoadDNN might occasionally
    take up to 16 seconds to complete.

    protected void Page_Load(object sender, EventArgs e)
    {
    Thread tLoadDNN = new Thread(new ThreadStart(LoadDNN));
    tLoadDNN.Start();
    Response.Redirect("Default1.htm");
    }
     
    Mark Huebner, Jul 2, 2006
    #1
    1. Advertising

  2. The default behavior of Response.Redirect is to abort the thread.
    If you don't want this to happen you can pass False to Response.Redirect's
    optional second parameter.
    Response.Redirect("SomePage.aspx", false);

    Here's more info:
    http://windowssdk.msdn.microsoft.com/en-us/library/a8wa7sdt.aspx

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net



    "Mark Huebner" <> wrote in message
    news:...
    >I have an aspx web page with the following C# code in the page load event.
    >Can somebody tell me if the Response.Redirect() will cause my tLoadDNN
    >thread to stop executing before it is finished? tLoadDNN might
    >occasionally take up to 16 seconds to complete.
    >
    > protected void Page_Load(object sender, EventArgs e)
    > {
    > Thread tLoadDNN = new Thread(new ThreadStart(LoadDNN));
    > tLoadDNN.Start();
    > Response.Redirect("Default1.htm");
    > }
    >
     
    Steve C. Orr [MVP, MCSD], Jul 2, 2006
    #2
    1. Advertising

  3. Mark Huebner

    Mark Huebner Guest

    If the second parameter is "false", does that mean the Response.Redirect
    won't redirect to the new URL until the thread finishes executing? I would
    like it to redirect immediately to the new URL while the thread continues to
    execute.

    "Steve C. Orr [MVP, MCSD]" <> wrote in message
    news:...
    > The default behavior of Response.Redirect is to abort the thread.
    > If you don't want this to happen you can pass False to Response.Redirect's
    > optional second parameter.
    > Response.Redirect("SomePage.aspx", false);
    >
    > Here's more info:
    > http://windowssdk.msdn.microsoft.com/en-us/library/a8wa7sdt.aspx
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://SteveOrr.net
    >
    >
    >
    > "Mark Huebner" <> wrote in message
    > news:...
    >>I have an aspx web page with the following C# code in the page load event.
    >>Can somebody tell me if the Response.Redirect() will cause my tLoadDNN
    >>thread to stop executing before it is finished? tLoadDNN might
    >>occasionally take up to 16 seconds to complete.
    >>
    >> protected void Page_Load(object sender, EventArgs e)
    >> {
    >> Thread tLoadDNN = new Thread(new ThreadStart(LoadDNN));
    >> tLoadDNN.Start();
    >> Response.Redirect("Default1.htm");
    >> }
    >>

    >
    >
     
    Mark Huebner, Jul 3, 2006
    #3
  4. Mark Huebner

    Mark Rae Guest

    "Mark Huebner" <> wrote in message
    news:OMUga$...

    > If the second parameter is "false", does that mean the Response.Redirect
    > won't redirect to the new URL until the thread finishes executing?


    Yes.

    > I would like it to redirect immediately to the new URL


    Response.Redirect("somepage.aspx", false);
    return;
     
    Mark Rae, Jul 3, 2006
    #4
    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. Charles A. Lackman
    Replies:
    2
    Views:
    8,100
    Charles A. Lackman
    Jan 11, 2006
  2. =?Utf-8?B?VHJveQ==?=

    Response.redirect does not redirect from .aspx page

    =?Utf-8?B?VHJveQ==?=, Oct 18, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    5,374
    Srowe1975
    Oct 15, 2008
  3. Son KwonNam
    Replies:
    11
    Views:
    2,646
    mr_organic
    Apr 9, 2004
  4. Sal
    Replies:
    1
    Views:
    1,036
  5. Ron Howard
    Replies:
    2
    Views:
    582
    Ron Howard
    Aug 11, 2004
Loading...

Share This Page