Esempio n. 1
0
 public ActionResult Login(LoginModel viewModel, string returnUrl)
 {
     if (ModelState.IsValid)
     {
         if (Membership.ValidateUser(viewModel.Email, viewModel.Password))
         {
             FormsAuthentication.SetAuthCookie(viewModel.Email, viewModel.RememberMe);
             if (Url.IsLocalUrl(returnUrl))
                 return Redirect(returnUrl);
             return RedirectToAction("Index", "File");
         }
         else
             ModelState.AddModelError("", "Login or Password is incorrect");
     }
     return View(viewModel);
 }
 public ActionResult Login(LoginModel model)
 {
     if (ModelState.IsValid)
     {
         if (Membership.ValidateUser(model.UserName, model.Password))
         {
             FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
             return RedirectToAction("Index", "Home");
         }
         else
         {
             ModelState.AddModelError("", "The user name or password provided is incorrect.");
         }
     }
     return RedirectToAction("Index", "Home", model);
 }