コード例 #1
0
 public ActionResult Login(LoginModel model, string returnUrl)
 {
     if (ModelState.IsValid)
     {
         if (Membership.ValidateUser(model.UserName, model.Password))
         {
             FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
             if (Url.IsLocalUrl(returnUrl))
             {
                 return Redirect(returnUrl);
             }
             else
             {
                 return RedirectToAction("Index", "Home");
             }
         }
         else
         {
             ModelState.AddModelError("", "De gebruikersnaam of het wachtwoord is fout.");
         }
     }
     return View(model);
 }
コード例 #2
0
 public ActionResult Login(LoginModel model, string returnUrl)
 {
     if (ModelState.IsValid)
     {
         if (Membership.ValidateUser(model.UserName, model.Password))
         {
             FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
             if (Url.IsLocalUrl(returnUrl))
             {
                 return Redirect(returnUrl);
             }
             else
             {
                 return RedirectToAction("Index", "Home");
             }
         }
         else
         {
             ModelState.AddModelError("", "The user name or password provided is incorrect.");
         }
     }
     return View(model);
 }