Solved

C# - Thread being aborted issue

Posted on 2012-03-21
2
599 Views
Last Modified: 2012-03-21
Look at below code.  I developed a WCF Service.  I'm trying to verify user logging in.  When trying to redirect I receive an error - "Thread being aborted".  How do I resolve?  Why is this error occurring?

foreach (var results in APILogin.GetLogin(this.txtUserName.Text.ToString(),
                                                                       this.txtPassword.Text.ToString()))
{
    if (results.MustChangePassword == true)
    {
        Response.Redirect("ResetPassword.aspx");
        break;
    }
    else
    {
        Session["IsAdmin"] = results.IsAdmin;
        Response.Redirect("Download.aspx");
        break;
     }
}
0
Comment
Question by:CipherIS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 500 total points
ID: 37747576
Do Something like this(Assuming that this is Client Code):-

public void Process()
{
string redirectPage = "";
bool ShouldRedirect=false;
using(var APILogin=new ClientProxy())
{
foreach (var results in APILogin.GetLogin(this.txtUserName.Text.ToString(), 
                                                                       this.txtPassword.Text.ToString()))
{
    if (results.MustChangePassword == true)
    {
        ShouldRedirect=true;
        RedirectPage="ResetPassword.aspx";
        break;
    }
    else
    {
        Session["IsAdmin"] = results.IsAdmin;
        ShouldRedirect=true;
        RedirectPage="Download.aspx";
        break;
     }
}
}

if(ShouldRedirect)
Response.Redirect(RedirectPage);
}

Open in new window

0
 
LVL 1

Author Comment

by:CipherIS
ID: 37747651
I figured out that i needed to move the redirects to the bottom and implement a variable to determine to redirect.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question