コード例 #1
0
        private bool ValidateLogOn(LogOnModel model)
        {
            if (String.IsNullOrEmpty(model.Username))
            {
                ModelState.AddModelError("Username", "You must specify a username.");
            }
            if (String.IsNullOrEmpty(model.Password))
            {
                ModelState.AddModelError("Password", "You must specify a password.");
            }

            return ModelState.IsValid;
        }
コード例 #2
0
        public ActionResult LogOn(LogOnModel model)
        {
            if (!ValidateLogOn(model))
            {
                return View();
            }

            if (!String.IsNullOrEmpty(model.ReturnUrl))
            {
                return Redirect(model.ReturnUrl);
            }

            return RedirectToAction("Index", "Home");
        }