public ActionResult Login(LoginModel model, string returnUrl)
        {
            // if (model.UserName.Equals("adminuser",StringComparison.OrdinalIgnoreCase))
            if(FormsAuthentication.Authenticate(model.UserName,model.Password))
            {
                FormsAuthentication.RedirectFromLoginPage(model.UserName, model.RememberMe);
                if (!string.IsNullOrWhiteSpace(returnUrl))
                {
                    return Redirect(returnUrl);
                }

                return RedirectToAction("Index");
            }

            ModelState.AddModelError("UserName", "User not registered");

            return View(model);
        }
示例#2
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {
                return RedirectToLocal(returnUrl);
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return View(model);
        }