public ActionResult Login(UserViewModel model, string returnUrl) { if (ModelState.IsValid) { var username = model.Username; var password = model.Password; var userValid = SqLiteDatabase.Authenticate(username, password); if (userValid) { FormsAuthentication.SetAuthCookie(username, model.RememberMe); return(RedirectToAction("Index", "Main")); } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } return(View(model)); }