problem with if-clause and a problem with response.redirect

  • Thread starter Thread starter Roel
  • Start date Start date
R

Roel

Hello

I'm having two strange errors in a webapplication I'm developping.

Error one:
If have an IF-clause. When the expression is true, the program does not only
executes the if-part, it also executes a part of the else clause...

Error two:
When the if clause is true, I redirect the user to another page
-> Response.Redirect("../../app/start.aspx");
On this line the program goes to the catch - part.... and give the following
error:
Message:
Thread was being aborted.

Source:
mscorlib


This is the code:

if(User.Validate())
{
Session.Timeout = 10;
Session["UserName"] = User.gsUsername;
User = null;
sBuilderPassWord = null;
sBuilderUserName = null;
Response.Redirect("../../app/start.aspx");
}
else
{
User = null;
sBuilderPassWord = null;
sBuilderUserName = null;
lblLogin.Text = "Verkeerde gebuikersnaam of paswoord.";
}
}

catch(Exception ex)
{
Response.Redirect ("../../app/error.aspx?errsource=" + ex.Source +
"&errmsg=" + ex.Message + "&errstack=" + ex.StackTrace);
}

Many thanks for your help

Roel
 
1. If & else clauses cannot execute together.
Try to find what it is that confuses you.
Maybe the value of lblLogin is already set?
2. Thread was being aborted.
Is caused by redirecting the page which aborts the thread.
Try to raise a flag and redirect at the end of the page.
 
Back
Top