G
Guest
I have a problem with thread execution after calling response.redirect() in a
web form.
Basically, I want the thread to continue to work (e.g. do some long database
work) but want to redirect immediately to another page, so that the user does
not have to wait.
I tried the wollowing exemple with two webforms webform1.aspx and
webform2.aspx : WebForm1.aspx just has one button which, when clicked,
executes the following method
private void Button1_Click(object sender, System.EventArgs e)
{
Server.ScriptTimeout = 60; // One minute
Response.Redirect("WebForm2.aspx",false);
Response.Flush();
Response.Close();
Thread.Sleep(10000); // Simulate the work to do
}
When WebForm1 Button1 is clicked, the false option in the Response.Redirect
method says that thread execution should continue. Then, as Response.Flush()
and Response.Close() are called, the Redirect should take place immediatly.
However, when I try (under IIS6) the browser waits for the Sleep command to
finish and only redirects afterwards. This does not seem to be the correct
behavior.
Any ideas of what I am missing ?
Robert
web form.
Basically, I want the thread to continue to work (e.g. do some long database
work) but want to redirect immediately to another page, so that the user does
not have to wait.
I tried the wollowing exemple with two webforms webform1.aspx and
webform2.aspx : WebForm1.aspx just has one button which, when clicked,
executes the following method
private void Button1_Click(object sender, System.EventArgs e)
{
Server.ScriptTimeout = 60; // One minute
Response.Redirect("WebForm2.aspx",false);
Response.Flush();
Response.Close();
Thread.Sleep(10000); // Simulate the work to do
}
When WebForm1 Button1 is clicked, the false option in the Response.Redirect
method says that thread execution should continue. Then, as Response.Flush()
and Response.Close() are called, the Redirect should take place immediatly.
However, when I try (under IIS6) the browser waits for the Sleep command to
finish and only redirects afterwards. This does not seem to be the correct
behavior.
Any ideas of what I am missing ?
Robert