-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: SureshScribnar
Message 3 in Discussion


When we sue the Response.End or Response.Redirect with single parameter or 
Response.Redirect with the second parameter value true, the ASP.NET script engine sets 
the neccessary HTTP header to redirect the request and stops the execution of the 
page. ASP.NET engine does stop the execution in a way which actually confueses 
everyone. It aborts the thread running the request. If you have done Threading in 
.NET, you will know that the ThreadAbortException is thrown whenever a thread is 
aborted. But, this exception will not be shown as error to the users until or unless 
you use Response.End or Response.Redirect inside try .catch block.  
So, how to handle this scenario? 
The best way is to use the Response.End or Response.Redirect outside the try..catch 
block. Or if you have to use it inside the try..catch block, just make sure that you 
have a catch block catching the System.Threading.ThreadAbortException as the first 
catch block in your try catch statement and simply leave the catch block blank. This 
is to make sure that the exception is  handled graciously. 
The above serves as the answer to the question. 
But if you're wondering what happens when we use Response.End or Response.Redirect 
outside the try...catch block. Isn't the exception thrown at that time? 
ITs still thrown. But, since when you use Response.Redirect to redirect, the 
information is immediately given to the client browser and the browser goes to the 
redirected URL. But in the server, the thread which was running the code is also 
destroyed. This way, the exception is never thrown to the browser. 
  
Regards, 
Suresh Kumar R 
 

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to