简体   繁体   中英

Quick Fix Needed: Login Re-Direct After Validation

Thanks in advance for your assistance.

I have a login form that validates properly if incorrect login credentials are put in, however if the right login credentials are put in it just reloads the page instead of going to the specified re-direct page. What am I missing?

Here is the code-behind:

protected void btnLogin_Click1(object sender, EventArgs e)
    {



        this.lblToken.Text = response.Token.ToString();
        int?[] cases = response.CaseNum;

        //Session.Add("Username", this.txtUsername.Text);   //User must re-login after an hour, since the token expires.
        //Session.Add("Password", this.txtPassword.Text);
        //Session.Add("AuthCode", this.txtAuthCode.Text);

        Session.Add("Token", response.Token);
        Session.Add("TokenExpires", DateTime.Now.AddHours(1));
        Session.Add("Cases", cases);
        Session.Add("PartyNameId", response.PartyNameID);

        if (response.Error != "")
            {
                this.lblErrorMessage.Text = response.Error;
                this.lblErrorMessage.Visible = true;
            }

        if (response.Error == "")
            {
                Response.Redirect("ListCases.aspx");
            }

Maybe response.Error is null?

Always try to use String.IsNullOrEmpty or IsNullOrWhitespace when testing on strings, it's safer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM