public ActionResult Login(LoginViewModel model)
        {
           // FormsAuthentication.SetAuthCookie(model.Email, false, FormsAuthentication.FormsCookiePath);
           // HttpContext.User.Identity.Name = "sdf";
       
          
            MyPrincipal principal = new MyPrincipal(model.Email,model.Password);
            if (!principal.Identity.IsAuthenticated)
            {
               
            }
            else
            {
                FormsAuthentication.SetAuthCookie(model.Email, false, FormsAuthentication.FormsCookiePath);
                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(model.Email, false, 5);

                FormsIdentity identy = new FormsIdentity(ticket);
                HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket));
                Response.Cookies.Add(cookie);
                //User.Identity.
                System.Web.HttpContext.Current.User = principal;
          
                // 如果用户通过验证,则将用户信息保存在缓存中,以备后用 
                // 在实际中,朋友们可以尝试使用用户验证票的方式来保存用户信息,这也是.NET内置的用户处理机制 
               // HttpContext.GetOwinContext().Authentication.
               // var Muser = User as principal;
              //  User = principal;
                Hashtable userMessage = new Hashtable();
                userMessage.Add("UserID", model.Email);
                userMessage.Add("UserPassword", model.Password);
                //Cache CA = new Cache();
                //CA.Insert("UserMessage", userMessage);

                System.Web.HttpContext.Current.Cache.Insert("UserMessage", userMessage);
                //System.Web.HttpContext.Current.Cache.Insert()
                
            //  Cache.Insert("UserMessage", userMessage); 
                
              
            } 
           // HttpContext.GetOwinContext().Authentication.User.Identity.IsAuthenticated
           // User.Identity.u
            UserB.InsertUser(new User { Name = "shens" });
          
            //if (!ModelState.IsValid)
            //{
            //    return View();
            //}
            return View("XuLogin");
          //  this.RedirectToAction("xulogin","account")
           
        }
        public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            // 这不会计入到为执行帐户锁定而统计的登录失败次数中
            // 若要在多次输入错误密码的情况下触发帐户锁定,请更改为 shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
            switch (result)
            {
                case SignInStatus.Success:
                    return RedirectToLocal(returnUrl);
                case SignInStatus.LockedOut:
                    return View("Lockout");
                case SignInStatus.RequiresVerification:
                    return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
                case SignInStatus.Failure:
                default:
                    ModelState.AddModelError("", "无效的登录尝试。");
                    return View(model);
            }
        }
        public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
            switch (result)
            {
                case SignInStatus.Success:
                    return RedirectToLocal(returnUrl);
                case SignInStatus.LockedOut:
                    return View("Lockout");
                case SignInStatus.RequiresVerification:
                    return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
                case SignInStatus.Failure:
                default:
                    ModelState.AddModelError("", "Invalid login attempt.");
                    return View(model);
            }
        }