Пример #1
0
        public ActionResult _LogOn(LogOnModel model, string returnUrl)
        {
            returnUrl = "";
            if (ModelState.IsValid)
            {
                if (_membership.ValidateUser(model.UserName, model.Password))
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                        && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    {
                        return Redirect(returnUrl);
                    }
                    else
                    {
                        return RedirectToAction("Index", "Home");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Пример #2
0
 //
 // GET: /Account/LogOn
 public PartialViewResult _LogOn()
 {
     var model = new LogOnModel();
     return PartialView();
 }