Solved

C# - Thread being aborted issue

Posted on 2012-03-21
2
578 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
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now