dottext学习笔记4 登陆页面
来源:互联网 发布:resnet caffe github 编辑:程序博客网 时间:2024/06/03 14:59
1 页面设计
<form id="frmLogin" method="post" runat="server">
<asp:textbox id="tbUserName" runat="server" CssClass="Textbox"></asp:textbox><br>
<asp:requiredfieldvalidator id="Required_User" runat="server" ErrorMessage="xx" ControlToValidate="tbUserName"/>
<table runat="server" id="tbAuthenCode">
<p style="MARGIN: 4px 0px 0px 70px">
给textbox增加onKeyPress属性
tbUserName.Attributes.Add("onKeyPress","checkEnter(event,this)");
tbPassword.Attributes.Add("onKeyPress","checkEnter(event,this)");
加载js代码到当前页面
this.RegisterClientScriptBlock("LoginScript",sr.ReadToEnd());
2 代码实现
密码认证
IsValidPassword,把文本密码hash散列,跟数据库中的密码字符串比较
密码散列:
password = password.ToLower();
Byte[] clearBytes = new UnicodeEncoding().GetBytes(password);
Byte[] hashedBytes = ((HashAlgorithm) CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);
return BitConverter.ToString(hashedBytes);
验证通过后设Ticket
FormsAuthentication.SetAuthCookie(username,persist);
获取当前用户名:HttpContext.Current.User.Identity.Name
注销:
HttpContext.Current.Response.Cookies.Clear();
System.Web.Security.FormsAuthentication.SignOut();
- dottext学习笔记4 登陆页面
- dottext学习笔记1 配置
- dottext学习笔记2 master构造
- dottext学习笔记3 URL重写
- Dottext的lucene使用笔记
- spring security2学习笔记二(自定义数据结构及登陆页面)
- QT学习笔记4---登陆对话框
- 登陆模块学习笔记
- springsecurity2学习笔记三(登陆后与struts结合、自定义访问拒绝页面)
- [ExtJS5学习笔记]第二十五节 利用window.open()函数实现ExtJS5的登陆页面跳转
- python学习笔记之:用urlllib库实现后台管理员登陆页面扫描
- Laravel 学习笔记--登陆注册
- 学习笔记3(登陆实现)
- python日常学习笔记4--模拟登陆知乎
- 登陆页面
- 登陆页面
- 登陆页面
- 登陆页面
- 利用Microsoft Html Help Workshop制作chm文件
- dottext学习笔记3 URL重写
- C#操作Excel---基础篇
- vs2005 unicode问题的解决
- Windows下直接运行Linux程序的可行性
- dottext学习笔记4 登陆页面
- 做个居家好男人,呵呵~
- 大家帮忙找一个实习单位!无分可散!不好意思!
- OWC 的应用 - 柱状图(VB.NET)
- About study
- 一个前文化部长的价值观
- 变形记之中国篇
- struts笔记(一)
- Connection大全