Something really odd is happening to my MVC 4 project. Everything was fine, I was able to login perfectly... And after a long-time being logged on (about 2 hours), I log out and log on another account, It's not working... There is no error showing up, I have no track for what is wrong... I press "login" button and nothing happens. But if I do it with that previous version project (the same name) everything is fine.

Any body here ever experiences something like this? I need your help. Thanks in advance! You would save my life.

[HttpPost]
    public ActionResult login(User user, string returnUrl)
    {
        if (ModelState.IsValid)
        {
            using (QuanlybangiayEntities3 db = new QuanlybangiayEntities3())
            {
                string username = user.HOVATEN;
                string pass = user.PASSWORD;

                bool UserValid = db.Users.Any(k => k.HOVATEN == username && k.PASSWORD == pass);
                if (UserValid)
                {
                    MigrateShoppingCart(username);

                    FormsAuthentication.SetAuthCookie(username, false);
                    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 &&
                        returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))

                        return Redirect(returnUrl);
                    else
                        return RedirectToAction("Index", "Product");
                }
                else
                    ModelState.AddModelError("", "Tên hoặc mật khẩu không đúng!");
            }
        }
        return View(user);
    }

Related posts

Recent Viewed