Redirect instantaneously & continue processing page

C

CK

I have a web page called PageOne.aspx which is supposed to do a long
process but I don't need to show any results to the client, so I want
to redirect the client to PageTwo.aspx right in the beginning of the
Page_Load and then continue with the long process.

So I've tried using Response.Redirect("http://mysite.com/PageTwo.aspx",
false) but the customer is not getting the response only until I finish
processing the whole page.

So I've tried adding Response.Flush();Response.Close(); but it does not
work properly. The first time I go to PageOne I get redirected right a
way but it will cause IE to display "page can not be displayed" instead
of redirecting to PageTwo.aspx, and then if I try again to go to
PageOne in that same browser it will take a long time until it gets to
the "page not found". [caching?]

But if try testing that same page with Wget, perl get they seem to
follow to PageTwo.aspx without incidence.

In short how do you redirect a customer instantaneously to another page
while the first page can still continue doing stuff after the customer
gets the redirect message?
 
K

Kevin Spencer

Try using Threading.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
C

CK

Thanks,
1) I knew that threading is an option but will I still be able to use
the Session to set values so other pages can read the result?

2) what is the official way to redirect and continue processing the
page?
 
K

Kevin Spencer

Hi CK,
1) I knew that threading is an option but will I still be able to use
the Session to set values so other pages can read the result?

Yes. However, that isn't going to be your greatest issue. Be sure to read up
on Threading before you try to use it, and remember that a Page class's
lifetime is very brief.
2) what is the official way to redirect and continue processing the
page?

There is none. A redirect is a header that is added to the Response. It
tells the browser to retrieve the URL it indicates. It can't be sent until
the Response is sent.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 

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,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top