예제 #1
0
 public ActionResult LogOn(string name, string password, string returnUrl)
 {
     if (_authenticationProvider.Authenticate(name, password))
     {
         // Assign a default redirection destination if not set
         returnUrl = returnUrl ?? Url.Action("Index", "Admin");
         // Grant cookie and redirect
         _authenticationProvider.SetAuthCookie(name, false);
         return(Redirect(returnUrl));
     }
     else
     {
         ViewData["lastLoginFailed"] = true;
         return(View());
     }
 }
예제 #2
0
        public ActionResult Login(string name, string password, string returnUrl)
        {
            if (formsAuth.Authenticate(name, password))
            {
                // Назначить место перенаправления по умолчанию,
                // если оно не назначено
                returnUrl = returnUrl ?? Url.Action("Index", "Admin");

                // Установить cookie-набор и перенаправить
                formsAuth.SetAuthCookie(name, false);
                return(Redirect(returnUrl));
            }
            else
            {
                ViewData["lastLoginFailed"] = true;
                return(View());
            }
        }