Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

C# - Thread being aborted issue

Posted on 2012-03-21
2
Medium Priority
?
604 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

688 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