Solved

C# - Thread being aborted issue

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
performance issue in asp web 5 30
Call windows 10 virtual keyboard from windows forms app 2 34
VB.Net Tranfer data between to VB.Net apps 8 25
VB.NET 2008 - SQL Timeout 9 24
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 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