Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8799763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:24:37+00:00 2026-06-14T00:24:37+00:00

Recently we’ve been getting System.Threading.ThreadAbortExceptions from an ASP.NET webservice that posts data to a

  • 0

Recently we’ve been getting System.Threading.ThreadAbortExceptions from an ASP.NET webservice that posts data to a payment server each night.

The webservice is a standard .asmx page that gets called from another client.

Inside the page I have a foreach loop that iterates through many payment rows in a database:

foreach (var obtRow in readyToBeCaptured)
{    
    try
    {
        status = dibs.GetPagePost(...);  
        // handle status here
    }
    catch (ThreadAbortException tex)
    {
        SingletonLogger.Instance.Error(string.Format("Transactionhandler - Could not Capture, Thread was aborted. {0}", tex.Message), tex);     
    }
    catch (Exception ex)
    {
        SingletonLogger.Instance.Error(string.Format("Transactionhandler - Could not Capture, statuscode: {0}, message: {1}.", status, ex.Message), ex);             
    }
}

The strange thing is I get a log entry from catch(ThreadAbortException tex) block when this error occurs, but then the code breaks out and is caught in another try catch block further up the call tree. Ideally I would have the code inside the foreach loop to continue

This is the GetPagePost method

private bool GetPagePost(string url, NameValueCollection nameValueCollection, string userName, string password)
{
    WebClient client = new WebClient();
    if (userName != "")
    {
        client.Credentials = new NetworkCredential(userName, password);
    }
    foreach (string str in nameValueCollection.AllKeys)
    {
        this._callCollection.Add(str, nameValueCollection[str]);
    }
    StringBuilder builder = new StringBuilder();
    builder.Append("DIBS.NET/1.2.0 ( ");
    builder.Append("OS ").Append(Environment.OSVersion.Platform).Append(" ").Append(Environment.OSVersion.Version).Append("; ");
    builder.Append(".NET CLR ").Append(Environment.Version).Append("; ");
    builder.Append("User ").Append(Environment.UserName).Append("; ");
    builder.Append("Domain ").Append(Environment.UserDomainName).Append("; ");
    builder.Append(" ) ");
    client.Headers.Add("User-Agent", builder.ToString());
    try
    {
        byte[] bytes = client.UploadValues(url, "POST", nameValueCollection);
        this._httpStatus = 200;
        this._httpBody = Encoding.UTF8.GetString(bytes);
        return true;
    }
    catch (WebException exception)
    {
        this._httpBody = exception.Message;
        this._httpStatus = (int) exception.Status;
    }
    catch (UriFormatException exception2)
    {
        this._httpBody = exception2.Message;
        this._httpStatus = -9999;
    }
    catch (Exception exception3)
    {
        this._httpBody = exception3.Message;
        this._httpStatus = -99999;
    }
    return false;
}} 

Why is this error occuring and how can I prevent the code from breaking out of the foreach loop?
I’ve been looking at a few other posts here on StackOverflow but they seem to relate to the usage of Reponse.Redirect which I don’t use.

Thanks

/Jens

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T00:24:39+00:00Added an answer on June 14, 2026 at 12:24 am

    I have a similar issue. I think IIS is terminating your thread for taking too long. From your description “I have a foreach loop that iterates through many payment rows in a database”, you may be able to restructure your app to process each row individually. Create a webmethod to send the rows to the client, then have the client iterate the transactions one at a time and process them in a different webmethod. Then you can handle exceptions that occur and keep going. You may even be able to process many at once using Parallel.ForEach

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I have been investigating the possibilities of caching in ASP.NET. I rolled my
Recently, I've been dealing with an error with accessing MAPI via the .NET framework
Recently, I was writing a class in which I discovered that I could reduce
Recently I've been doing quite the project mostly working with the DateTime class. Now,..
Recently, I am going to make a instant-notification system for my website. I heard
Recently I've been dealing with texts with mixed languages, including Chinese, English, and even
Recently I've been thinking about how to transform a complex polygon into a non-complex
Recently I've been experimenting with the use of the Func<T> class, and so far
Recently I'm doing some work on RTMP streaming, that is using Flowplayer to integrate
Recently I've noticed that on occasion I do not get a mayorship notification when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.