Ramco Ramco

Ramco Ramco

  • 442
  • 3.4k
  • 528.4k

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)