public ActionResult Login(LoginVM model) { try { if (ModelState.IsValid) { BACommercesEntities1 db = new BACommercesEntities1(); var user = db.Users.FirstOrDefault(x => x.Email == model.Email && x.Password == model.Password); Session["UserName"] = user.UserName; if (user != null) { FormsAuthentication.SetAuthCookie(user.UserName, true); return(RedirectToAction("Index", "Home")); } } } catch { ViewBag.Message = "Kullanıcı Adı veya Parola Yanlış."; } return(View()); }