登录尝试失败

编程入门 行业动态 更新时间:2024-10-08 13:34:57
本文介绍了登录尝试失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在创建一个新的应用程序..我成功创建了一个登录页面..现在我需要修改登录页面..只有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...

更多推荐

登录尝试失败

本文发布于:2023-11-09 23:26:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573734.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!