Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a valid use for Response.Redirect("SomeURL", false)?

Tags:

asp.net

In ASP.NET I frequently use Response.Redirect to redirect the end user to another page on my system. I always set the second parameter to true to immediately end the response.

For the life of me, I can't think of a reason why anybody would ever set that parameter to false. What's the point of continuing generating a page when the end user's browser is just going to be redirected to a different page immediately?

like image 623
Aheho Avatar asked Jan 30 '11 15:01

Aheho


2 Answers

Response.Redirect does not mean that The Page-lifecycle has ended on the server, it just sends a header to the client.

Perhaps you want to redirect the user first and THEN save his large amount of uploaded data to the database?

HttpServerUtility.Transfer by the way does terminate the Page-lifecycle, but it does not send a header, it simply serves a different page.

like image 195
Caspar Kleijne Avatar answered Oct 27 '22 10:10

Caspar Kleijne


Response.Redirect(..., true);

client will be sent the redirect for the new page, processing will stop as a thread abort will occur

Response.Redirect(..., false);

client will be sent the redirect for the new page, current page will be allowed to continue processing, perhaps some cleanup work to do or something else

client will never see the results from current page in either cases

like image 44
Kris Ivanov Avatar answered Oct 27 '22 11:10

Kris Ivanov