PC Review


Reply
Thread Tools Rate Thread

Error - mscorlib : Thread was being aborted.

 
 
=?Utf-8?B?VC4=?=
Guest
Posts: n/a
 
      13th Aug 2005
I had the following code inside my app
try
{
// Open an ADO.NET db connection
// Do some db processing here

Response.Redirect("main.htm");
}
catch(Exception e)
{
}

The Response.Redirect("main.htm") state was generating the error 'mscorlib
: Thread was being aborted'. But when I took that statement out of the
try..catch block it ran fine. Why does Ressponse.Redirect cause an error
inside a try..catch statement?

Thanks in advance
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VC4=?=
Guest
Posts: n/a
 
      13th Aug 2005
Clarification: Actually its just the try{} block, runs fine in the
catch(Exceptione) {} block

"T." wrote:

> I had the following code inside my app
> try
> {
> // Open an ADO.NET db connection
> // Do some db processing here
>
> Response.Redirect("main.htm");
> }
> catch(Exception e)
> {
> }
>
> The Response.Redirect("main.htm") state was generating the error 'mscorlib
> : Thread was being aborted'. But when I took that statement out of the
> try..catch block it ran fine. Why does Ressponse.Redirect cause an error
> inside a try..catch statement?
>
> Thanks in advance

 
Reply With Quote
 
 
 
 
Brock Allen
Guest
Posts: n/a
 
      13th Aug 2005
A ThreadAbortException is thrown when Redirect is used - it's just how it
works. Why are you doing a catch(Exception e)? If your code can't "handle"
every exception, then I'd suggest not having the catch block there. If there's
a specific exception you know how to deal with, then use the catch (like
FormatException or SqlException for example). To be notified that there was
an unhandled exception (one you didn't catch) you should put a Application_Error
handler in global.asax; this is where your error logging should go.

-Brock
DevelopMentor
http://staff.develop.com/ballen



> I had the following code inside my app
> try
> {
> // Open an ADO.NET db connection
> // Do some db processing here
> Response.Redirect("main.htm");
> }
> catch(Exception e)
> {
> }
> The Response.Redirect("main.htm") state was generating the error
> 'mscorlib : Thread was being aborted'. But when I took that statement
> out of the try..catch block it ran fine. Why does Ressponse.Redirect
> cause an error inside a try..catch statement?
>
> Thanks in advance
>




 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on Joe Microsoft C# .NET 4 12th Mar 2007 10:59 AM
Understanding a 'thread was being aborted/mscorlib' exception darrel Microsoft ASP .NET 5 9th Mar 2006 05:16 PM
Thread A calls a delegate on Thread B but Thread A executes it!?!? Paul Tomlinson Microsoft C# .NET 4 3rd Feb 2005 11:09 PM
"Thread was being aborted" error in mscorlib - web project Elliot M. Rodriguez Microsoft ASP .NET 1 22nd Jan 2004 06:50 PM
Shut down thread - thread closes form, form doesn't close because thread calls it etc... Robin Tucker Microsoft VB .NET 4 17th Oct 2003 12:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:28 PM.