Ramco Ramco

Ramco Ramco

  • 461
  • 2.9k
  • 406k

Forms AUthentication

Jun 28 2021 10:50 AM

Hi

   How the below Forms Authentication code works - FormsAuthentication.SetAuthCookie(UserName,false);

[HttpPost]
        public ActionResult Login(string UserName , string Password)
        {
            int res = dbUser.Admin_Login(UserName , Password);
            if (res == 1)
            {
                TempData["msg"] = "login Successfully...!";
                FormsAuthentication.SetAuthCookie(UserName,false);
                return RedirectToAction("Index", "Location");
            }
            else
            {
                TempData["msg"] = "Admin id or Password is wrong...!";
            }
            return View();
        }

************ Web.Config

<authentication mode="Forms">
      <forms loginUrl="~/Home/Login" timeout="30" />
    </authentication>

Thanks


Answers (1)