Esempio n. 1
0
        public ActionResult Login()
        {
            bool isChecked = false;

            if (Request.Form["remember"] != null)
            {
                isChecked = true;
            }

            if (User_Controller.AuthenticateUser(Request.Form["USer name"].ToString(), Request.Form["password"].ToString()))//Authentication in database
            //if (FormsAuthentication.Authenticate(Request.Form["USer name"].ToString(), Request.Form["password"].ToString()))//Authentication in Web.config
            {
                FormsAuthentication.SetAuthCookie(Request.Form["USer name"].ToString(), isChecked);
                FormsAuthentication.RedirectFromLoginPage(Request.Form["USer name"].ToString(), isChecked);
                ViewBag.UserName = System.Web.HttpContext.Current.User.Identity.Name;
                return(RedirectToAction("index", "Home"));
            }

            else
            {
                TempData["AlertMessage"] = "Invalid";
                return(RedirectToAction("index", "Login"));
            }
        }