public ActionResult Login(RegisterUser user, string returnUrl)
        {

            var result = accountService.VaildUser(user.Email, user.Password);
            if (result.isSuccess)
            {
                //创建验证票subdomain  share cookie
                var ticket = new System.Web.Security.FormsAuthenticationTicket(user.Email, true, 30);
                string authTicket = System.Web.Security.FormsAuthentication.Encrypt(ticket);
                HttpCookie cookie = new HttpCookie(System.Web.Security.FormsAuthentication.FormsCookieName, authTicket);
                cookie.Domain = AppSettings.FormDomain;
                var userExtend = accountService.GetUserExtendInfo(user.Email);
                Session[user.Email] = userExtend.NickName == null ? "" : userExtend.NickName;
                Response.Cookies.Add(cookie);
                if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                    && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                {
                    return Redirect(returnUrl);
                }
                else
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            else
            {
                ViewBag.Error = result.ResultMsg;
            }
            return View();
        }
 /// <summary>
 /// 注册用户
 /// </summary>
 /// <param name="user">用户注册模型</param>
 /// <returns>View</returns>
 public ActionResult Register(RegisterUser user)
 {
     if (user != null && user.PasswordQuestion != null)
     {
         if (user.PasswordQuestion == "请选择密保查询问题")
         {
             ViewBag.PasswordQuestion = "请选择一个密保查询问题";
         }
     }
     if (!ModelState.IsValid || user == null ||
         user.VerificationCode == null || user.Email == null
         || Session["PictureCode"] == null)
     {
         return View("Register", user);
     }
     if (string.Compare(user.VerificationCode, Session["PictureCode"].ToString(), true) != 0)
     {
         ViewBag.VerificationCode = "验证码错误,请重试";
         return View("Register", user);
     }
     var membershipuser = new Membership();
     membershipuser.Users = new Users();
     membershipuser.Users.UserName = user.Email;
     membershipuser.MobilePIN = user.Mobile;
     membershipuser.Email = user.Email;
     membershipuser.Password = user.Password;
     var other = new OtherInformation();
     other.Address = "";
     other.Mobile = user.Mobile;
     other.QQ = user.QQ;
     other.Sex = SexCatalog.Male;
     other.NickName = user.NickName;
     other.PasswordQuestion = user.PasswordQuestion;
     other.PasswordAnswer = user.PasswordAnswer;
     var entityResult = accountService.AddUser(membershipuser, other);
     if (entityResult.isSuccess)
     {
         // 跳转到登录页面
         //System.Web.Security.FormsAuthentication.SetAuthCookie(user.Email, true);
         //Session[user.Email] = user.NickName == null ? "" : user.NickName;
         var ticket = new System.Web.Security.FormsAuthenticationTicket(user.Email, true, 30);
         string authTicket = System.Web.Security.FormsAuthentication.Encrypt(ticket);
         HttpCookie cookie = new HttpCookie(System.Web.Security.FormsAuthentication.FormsCookieName, authTicket);
         cookie.Domain = AppSettings.FormDomain;
         var userExtend = accountService.GetUserExtendInfo(user.Email);
         Session[user.Email] = userExtend.NickName == null ? "" : userExtend.NickName;
         Response.Cookies.Add(cookie);
         gloCache.UserCountAdd();
         return RedirectToAction("Index", "Home");
     }
     else
     {
         ViewBag.Error = entityResult.ResultMsg;
         return View("Register", user);
     }
 }