简体   繁体   English

需要快速修复:验证后重新登录

[英]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? 也许response.Error为null?

Always try to use String.IsNullOrEmpty or IsNullOrWhitespace when testing on strings, it's safer. 在对字符串进行测试时,请始终尝试使用String.IsNullOrEmpty或IsNullOrWhitespace,这更安全。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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