Aheho
Aheho

Reputation: 12821

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

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?

Upvotes: 5

Views: 3159

Answers (4)

Sunil Kumar Singh
Sunil Kumar Singh

Reputation: 1

Response.Rediect("any page like Default.aspx");

When the control reach on this statement our page will be jump to the page that is specified into the brackets. The page may be .aspx, .asp.htm etc...

Upvotes: -1

Kris Ivanov
Kris Ivanov

Reputation: 10598

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

Upvotes: 6

Caspar Kleijne
Caspar Kleijne

Reputation: 21864

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.

Upvotes: 6

giacoder
giacoder

Reputation: 980

Why not. May be you have some things to complete on this page before the processes of a page will be killed. Writing to file and then colsing it for example. Or making some changes in DB, with proper ending of connection.

Upvotes: 1

Related Questions