Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

C# - Thread being aborted issue

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Loops Section Overview
Suggested Courses

927 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