Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,
Please confirm me what is use of response.redirect second parameter true and false
ex
response.redirect("page.aspx",true);
what is work of true
Posted
Updated 30-Apr-12 21:22pm
v2

If you write the second parameter as true than it will throw an exception
i.e.
System.Threading.ThreadAbortException: Thread was being aborted.

because the running thread is ended and trying for another thread.
and if you write false than it will not show any exception.

Response.Redirect("page_name.aspx",true)<--Throw Exception.
Response.Redirect("page_name.aspx",false)<--Exception Free.

These links may help you
ThreadAbortException[^]
http://support.microsoft.com/kb/312629[^]
 
Share this answer
 
The second parameter of Response.Redirect is endResponse(see in tooltip of this function) which is boolean value that indicates whether to stop running the current page.

It depends on if you want to keep it alive or stop it.

Use "false" when you don't want to abort the thread i.e. false will cause the code to continue to execute. So lines of code which appear after the Response.Redirect will be executed. A "true" will just kill the thread so nothing further will execute, which in turn throws a ThreadAbortException.

So it's really based on how the rest of the code in that situation has to be executed. Generally you want to put calls to Response.Redirect at the end of an execution path so that nothing further needs to be executed. But many times that's not the case. It's just a matter of how you control the logic flow in the code.
 
Share this answer
 
Hi,

Bcoz whenever we moved from one page to another page that time previous page thread also running so stop the first page thread we need to write "FALSE" otherwise both thread running simultaneously and given Error...

Hope you can understand....!!!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900