zoukankan      html  css  js  c++  java
  • ASP.NET 登录身份验证 二 自定义模式(framework)

    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()里面竟然有保存身份验证的代码,非常的违规(导致我多花了几分钟找哪里保存信息了)。
  • 相关阅读:
    js中location.href的用法
    entityframework单例模式泛型用法
    [C#]从URL中获取路径的最简单方法-new Uri(url).AbsolutePath
    等到花儿也谢了的await
    ASP.NET MVC下的异步Action的定义和执行原理
    实际案例:在现有代码中通过async/await实现并行
    ASP.NET MVC Controllers and Actions
    扩展HtmlHelper
    iOS开发网络篇—XML数据的解析
    IOS学习:常用第三方库(GDataXMLNode:xml解析库)
  • 原文地址:https://www.cnblogs.com/zc22/p/958589.html
Copyright © 2011-2022 走看看