登录尝试失败 [英] Unsuccessful Login Attempts

查看:73
本文介绍了登录尝试失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个新的应用程序..我成功创建了一个登录页面..现在我需要修改登录页面..只有3次尝试才允许用户使用..如果用户错误地输入密码超过3次(在5分钟内)他的帐户必须被阻止..并且必须显示错误消息,因为您无法访问您的页面。



i已经厌倦了许多网站编码但请不要使用请帮助我任何一个

解决方案

试试这个,

  public  DateTime GetDt 
{
get {
if (ViewState [ GetDT] == null
{
ViewState [ GetDT] = DateTime。现在;
}
return (DateTime)ViewState [ GetDT]; }
set {ViewState [ GetDT ] = ; }
}
public int CNT
{
get
{
if (ViewState [ CNT] == null
{
ViewState [ CNT] = 0 ;
}
return int )ViewState [ CNT]; }
set {ViewState [ CNT ] = ; }
}

protected void uxLogin_Click( object sender,EventArgs e)
{
SqlDataAdapter ad = new SqlDataAdapter( 从x中选择1,其中Uname =' + uxTxtUserName.Text.Trim()+ '和PassWord =' + uxTxtPassword.Text.Trim()+ ',con);
DataTable dt = new DataTable();
ad.Fill(dt);
if (dt.Rows.Count < = 0
{
CNT = Convert.ToInt32(CNT)+ 1 ;
TimeSpan tm = DateTime.Now - GetDt;
if (CNT > 3 && tm.Minutes < 5
{
// 编写代码以显示错误信息。
}
}
else
{
CNT = 0 ;
GetDt = DateTime.Now;
}
}


然后考虑你自己的逻辑并尝试实现它。



例如,我的逻辑是......



1.带一个HiddenField或使用查看状态。



2.点击登录按钮,

- >更新此HiddenField或View State的值。

- >检查上述字段中包含的值是否超过3.

- >如果尝试值超过3,则将用户表中的一个字段更新为IsBlocked为真。



4.阻止用户并显示错误消息。



注意

登录后点击,首先转到用户表用户名并检查他的IsBlocked状态。如果它是假的,那么去密码检查和记录,否则显示消息你的帐户被阻止



谢谢。 ..

I am creating a new application..I created a login page successfully..Now I need to modify the login page ..Only 3 attempts only allowed for a user ..If the user wrongly enters the password more than 3 times(within 5 min) his account must be blocked..And error message must be shown as You cant access your page.

i have tired many sites coding but not use please help me any one

解决方案

Try this,

public DateTime GetDt
{
    get {
        if (ViewState["GetDT"] == null)
        {
            ViewState["GetDT"] = DateTime.Now;
        }
        return (DateTime)ViewState["GetDT"]; }
    set { ViewState["GetDT"] = value; }
}
public int CNT
{
    get
    {
        if (ViewState["CNT"] == null)
        {
            ViewState["CNT"] = 0;
        }
        return (int)ViewState["CNT"]; }
    set { ViewState["CNT"] = value; }
}

protected void uxLogin_Click(object sender, EventArgs e)
{
    SqlDataAdapter ad = new SqlDataAdapter("select 1 from x where Uname='" + uxTxtUserName.Text.Trim()+ "' and PassWord='"+uxTxtPassword.Text.Trim()+"'", con);
    DataTable dt = new DataTable();
    ad.Fill(dt);
    if (dt.Rows.Count <= 0)
    {
        CNT = Convert.ToInt32(CNT) + 1;
        TimeSpan tm = DateTime.Now - GetDt;
        if (CNT > 3 && tm.Minutes < 5)
        {
            //Write code to show error msg.
        }
    }
    else
    {
        CNT = 0;
        GetDt = DateTime.Now;
    }
}


Then think of your own logic and try to implement it.

For example, my logic would be...

1. Take one HiddenField or use View State.

2. On click of login button,
-> update value to this HiddenField or View State.
-> check whether the value contained in the above field exceeds 3.
-> if attempt value exceeds 3, then update one field in user table like "IsBlocked" to true.

4. Block user and show error message.

Note
On login click, first go to user table with the username and check his "IsBlocked" status. And if it is false, then go for password checking and logging, otherwise show message that "Your account is blocked".

Thanks...


这篇关于登录尝试失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆