public ActionResult Index(FormCollection objForm) { bool isChecked = false; if (Request.Form["remember"] != null) { isChecked = true; } if (UserControl.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); if (Request.QueryString["returnUrl"] != "" && Request.QueryString["returnUrl"] != null) { string sdf = Request.QueryString["returnUrl"]; return(Redirect(Request.QueryString["returnUrl"])); } 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")); } }