ASP.NET 登录身份验证 二 自定义模式(framework)
2007-11-13 23:53
387 查看
reference:
framework.supesoft.com/
Login.aspx页面分析:
button事件
{
判断页面输入是否正确,如果正确,则进入一个叫Messagebox的中间页面,里面有个button指向default.aspx
注意这里在CheckLogin()里面同时进行了以下操作:
private void Signin(sys_UserTable sUT)
{
System.Web.Security.FormsAuthenticationTicket tk = new FormsAuthenticationTicket(1,
sUT.UserID.ToString(),
DateTime.Now,
DateTime.Now.AddMinutes(30),
true,
"",
System.Web.Security.FormsAuthentication.FormsCookiePath
);
string key = System.Web.Security.FormsAuthentication.Encrypt(tk); //得到加密后的身份验证票字串
HttpCookie ck = new HttpCookie(System.Web.Security.FormsAuthentication.FormsCookieName, key);
//ck.Domain = System.Web.Security.FormsAuthentication.CookieDomain; // 这句话在部署网站后有用,此为关系到同一个域名下面的多个站点是否能共享Cookie
HttpContext.Current.Response.Cookies.Add(ck);
}
如果输入不正确,进入messagebox页面,里面有个Button指回login.aspx
}
感觉上说白了还是用了asp.net的security框架,而且有些代码写的不是很到位,没有single minded。比如就那个Checklogin()里面竟然有保存身份验证的代码,非常的违规(导致我多花了几分钟找哪里保存信息了)。
framework.supesoft.com/
Login.aspx页面分析:
button事件
{
判断页面输入是否正确,如果正确,则进入一个叫Messagebox的中间页面,里面有个button指向default.aspx
注意这里在CheckLogin()里面同时进行了以下操作:
private void Signin(sys_UserTable sUT)
{
System.Web.Security.FormsAuthenticationTicket tk = new FormsAuthenticationTicket(1,
sUT.UserID.ToString(),
DateTime.Now,
DateTime.Now.AddMinutes(30),
true,
"",
System.Web.Security.FormsAuthentication.FormsCookiePath
);
string key = System.Web.Security.FormsAuthentication.Encrypt(tk); //得到加密后的身份验证票字串
HttpCookie ck = new HttpCookie(System.Web.Security.FormsAuthentication.FormsCookieName, key);
//ck.Domain = System.Web.Security.FormsAuthentication.CookieDomain; // 这句话在部署网站后有用,此为关系到同一个域名下面的多个站点是否能共享Cookie
HttpContext.Current.Response.Cookies.Add(ck);
}
如果输入不正确,进入messagebox页面,里面有个Button指回login.aspx
}
感觉上说白了还是用了asp.net的security框架,而且有些代码写的不是很到位,没有single minded。比如就那个Checklogin()里面竟然有保存身份验证的代码,非常的违规(导致我多花了几分钟找哪里保存信息了)。
相关文章推荐
- asp.net forms 身份验证方式下跨域登录信息共享的实现方法
- ASP.NET Forms身份验证登录
- 实现基于 ASP.NET Forms 身份验证的跨子域单点登录
- asp.net登录 用Forms身份验证和基于角色的分目录访问
- asp.net用户身份验证时读不到用户信息的问题 您的登录尝试不成功。请重试。 Login控件
- ASP.NET中获取登录用户ID 用户身份验证
- asp.net中的窗体身份验证(完整篇之三:用户登录页面)
- 详解ASP.NET Core和ASP.NET Framework共享身份验证
- asp.net forms 身份验证方式下跨域登录信息共享的实现方法
- 两系统用asp.net forms 身份验证方式实现跨域登录信息共享
- asp.net中的窗体身份验证(完整篇之五:退出登录)
- 如何设置混合身份验证?— —或 'IIS APPPOOL\ASP.NET v4.0' 登录失败
- ASP.NET登录身份验证 一
- asp.net身份验证(登录控件),基于标准的sqlserver.(vs2005+sqlserver2005)
- asp.net中的窗体身份验证(完整篇之五:退出登录)
- asp.net身份验证(登录控件),基于标准的sqlserver.(vs2005sqlserver2005)
- asp.net用户身份验证时读不到用户信息的问题 您的登录尝试不成功。请重试。 Login控件
- 还在为身份验证引入的Microsoft.AspNet.Identity.EntityFramework导致多上下文,生成的DB改名困扰吗?
- ASP.NET Core 和 ASP.NET Framework 共享 Identity 身份验证
- asp.net中的窗体身份验证(完整篇之三:用户登录页面)