When is it best to use false as the second parameter of Response.Redirect, and when not?

In general, for .NET everyone recommends using:

Response.Redirect("url", false)

instead

Response.Redirect("url", true)

to avoid race conditions, since the latter, apparently, suddenly stops the process.

Is there a case where it makes sense to use trueinstead false?

Is it also falsemore suitable than truewhen the redirect is not a back link to the same aspx page, but redirected to another aspx page?

+2
source share
3 answers

true, , false, . ( , true , .)

, , ThreadAbortException, , , , . ASP.NET . , , .

, , . return; Response.Redirect(). (.. , return; ), , , runaway, - .

, Response.Redirect() . , , #, . Response.Redirect() - , , , , .

+2

false , Thread, / Response.Redirect().

, . Server

true , / Response.Redirect() .

, . Server

+1

Of course you want to use Response.Redirect("url", false)if it is in a block try catch.

Otherwise, it will throw a ThreadAbortException.

try {
  Response.Redirect("url", false);
}
catch(Exception ex) {
   // Log exception
}
0
source

All Articles