예제 #1
0
 public ActionResult signup(tblLogin member)
 {
     using (var context = new formAuthenticationEntities())
     {
         member.status = true;
         context.tblLogins.Add(member);
         context.SaveChanges();
     }
     return(RedirectToAction("login"));
 }
예제 #2
0
        public ActionResult login(Models.Membership member)
        {
            using (var context = new formAuthenticationEntities())
            {
                bool isValid = context.tblLogins.Any(x => x.userName == member.userName && x.password == member.password);
                if (isValid)
                {
                    FormsAuthentication.SetAuthCookie(member.userName, false);
                    return(RedirectToAction("Index", "Home"));
                }

                ModelState.AddModelError("", "Invalid username or password");
                return(View());
            }
        }