Exemple #1
0
 public ActionResult Login(UserLogin ul, string returnUrl)
 {
     try
     {
         if (ModelState.IsValid)
         {
             if (_mp.ValidateUser(ul.UserName, ul.Password))
             {
                 FormsAuthentication.SetAuthCookie(ul.UserName, false);
                 return Redirect(returnUrl ?? Url.Action("Index", "Home"));
             }
             else
             {
                 ModelState.AddModelError(string.Empty, "Usuario y contraseña no válidos");
                 return View(ul);
             }
         }
         else
         {
             return View(ul);
         }
     }
     catch (Exception ex)
     {
         ModelState.AddModelError(string.Empty, ex.Message);
         return View(ul);
     }
 }
Exemple #2
0
 // GET: Login
 public ActionResult Login()
 {
     UserLogin ul = new UserLogin();
     return View(ul);
 }