ASP.NET登录验证
protected void btnLogin_Click(object sender, EventArgs e)
{
string username = txtUserName.Value.Trim();
string userpassword = txtUserPassword.Value.Trim(); if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(userpassword))
{
Common.MessageBox.Show(this, "账号和密码不能为空!");
}
else
{
string ip = Request.UserHostAddress;
BLL.ProxyInfo bllMember = new ProxyInfo();
string encrytpswd = DimoNetwork.Common.DEncrypt.TextEncrypt.MD5EncryptPassword(userpassword);
int reuslt;
Model.UserInfo userInfo= bllMember.ProxyLogin(username, encrytpswd, ip, out reuslt);
if (mProxyInfo != null)
{
//判断用户是否被冻结
if (userInfo.freezeState)
{
Common.MessageBox.Show(this, "您的账号已被冻结,请联系你的上级代理!");
}
else
{
Common.Cache.DimoCache.Default.Save<Common.Cache.SessionCache>("MemberSession", userInfo);
Common.MessageBox.ShowAndRedirects(this.Page, "", "main.aspx");
}
}
else
{
AddLoginErrorCount();
if (GetLoginErrorCount() >= )
{
Common.MessageBox.Show(this, "账号或密码错误次数过多,账号被锁定20分钟,请20分钟后重试!");
txtUserName.Value = "";
txtUserPassword.Value = "";
btnLogin.Visible = false;
}
else
{
Common.MessageBox.Show(this, "账号或密码错误!");
}
}
}
}
/// <summary>
/// 获得登陆错误次数
/// </summary>
/// <returns></returns>
protected int GetLoginErrorCount()
{
int logincount = ;
object logincountcache = Common.Cache.Default.Get<Common.Cache.SessionCache>(lockcachekey);
if (logincountcache != null)
{
logincount = Convert.ToInt32(logincountcache);
}
return logincount;
}
/// <summary>
/// 修改用户登录错误次数
/// </summary>
protected void AddLoginErrorCount()
{
object logincountcache = Common.Cache.DimoCache.Default.Get<Common.Cache.SessionCache>(lockcachekey);
if (logincountcache != null)
{
int logincount = Convert.ToInt32(logincountcache);
Common.Cache.Default.Save<Common.Cache.SessionCache>(lockcachekey,logincount + );
}
}
ASP.NET登录验证的更多相关文章
- C# asp.net 抓取需要登录的网页内容 抓取asp.net登录验证的网站
private void btnASPNET_Click(object sender, EventArgs e) { Dictionary<string, s ...
- asp.net登录验证FormsAuthenticationTicket和FormsAuthentication类
登录部分使用的类 FormsAuthentication 为 Web 应用程序管理 Forms 身份验证服务. 配置启用身份验证,WEB.config配置: <system.web> ...
- ASP.NET 登录验证 ihttpmoudle
问题: 1.iis版本不同(IIS7.0,应用程序池采用的是集成模式,换成经典模式才起作用.) 在 IIS 7 以下的版本中,应用以下配置: <system.web> <httpMo ...
- asp.net登录状态验证
文章:ASP.NET 登录验证 文章:ASP.NET MVC下判断用户登录和授权状态方法 文章:.net学习笔记---HttpHandle与HttpModule 第一篇文章,介绍了 1)早期的Base ...
- Asp.NetMVC利用LigerUI搭建一个简单的后台管理详解(函登录验证)
上一篇 Asp.Net 中Grid详解两种方法使用LigerUI加载数据库数据填充数据分页 了解了LigerUI 中Grid的基本用法 现在结合上一篇的内容做一个简单的后台管理,当然也有前台的页面 ...
- ASP.NET MVC5入门3之登录验证
参考: HTML页面模版: http://www.ui.cn/detail/70262.html(第38个) MVC后台代码参考: http://www.oschina.net/p/nfine 开发环 ...
- ASP.NET MVC 登录验证
好久没写随笔了,这段时间没 什么事情,领导 一直没安排任务,索性 一直在研究代码,说实在的,这个登录都 搞得我云里雾里的,所以这次我可能也讲得不是 特别清楚,但是 我尽力把我知道的讲出来,顺便也对自 ...
- ASP.NET MVC4 Forms 登录验证
Web.config配置: 在<system.web>节下: <authentication mode="Forms"> <forms loginUr ...
- ASP.NET MVC3 实现用户登录验证
自定义一个授权筛选器类,继承于AuthorizeAttribute: using System; using System.Web; using System.Web.Mvc; namespace M ...
随机推荐
- Centos 安装 mysql tar.gz
http://www.cnblogs.com/coderls/p/6848873.html
- pytorch 损失函数
pytorch损失函数: http://blog.csdn.net/zhangxb35/article/details/72464152?utm_source=itdadao&utm_medi ...
- android 界面设计
wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetric ...
- 【高速接口-RapidIO】1、RapidIO协议概述
一.RapidIO背景介绍 RapidIO是由Motorola和Mercury等公司率先倡导的一种高性能. 低引脚数. 基于数据包交换的互连体系结构,是为满足和未来高性能嵌入式系统需求而设计的一种开放 ...
- python 字典详细使用
1. 字典 字典是无序.可变序列. 定义字典时,每个元素的键和值用冒号分隔,元素之间用逗号分隔,所有的元素放在一对大括号“{}”中. 字典中的键可以为任意不可变数据,比如整数.实数.复数.字符串.元组 ...
- mysql命令行创建表,插入表数据
create table t_hero( id int unsigned auto_increment primary key, name varchar(10) unique not null, a ...
- outline和outline-offset属性实现简单的缝边效果
如果现在有个需求,让你实现下面的样式,你会怎么做呢? 我首先想到的是用 border + box-shadow 实现,代码如下 div { margin: 50px auto; width: 200p ...
- Aseprite入门教程
因为最近在学cocos2d-x和vs搭配做手机游戏开发,想自己做一些素材,所以找到了这款软件,Aseprite v1.1.12.刚安装上时也是不懂该怎么操作,随着逐渐地摸索,对初始的使用有了一些了解. ...
- 神经网络架构pytorch-MSELoss损失函数
MSELoss损失函数中文名字就是:均方损失函数,公式如下所示: 这里 loss, x, y 的维度是一样的,可以是向量或者矩阵,i 是下标. 很多的 loss 函数都有 size_average 和 ...
- deepin卸载mysql并安装设置mysql5.7
mysql完全卸载以及安全安装 完全卸载 sudo apt purge mysql-* sudo rm -rf /etc/mysql/ /var/lib/mysql sudo apt autoremo ...