public ActionResult Login(LoginModel objModellogin) { var strErrorMsg = string.Empty; var strExpiryValMsg = string.Empty; try { if (objModellogin.LoginID != null) { //strExpiryValMsg = UserAuthenticator.UserAuthenticator.ValidationExpiryMsg(DateTime.Now); if (string.IsNullOrEmpty(strExpiryValMsg)) { var userInfo = objUser.GetUserInformation(null, objModellogin.LoginID).FirstOrDefault(); if (userInfo != null) { if (UserAuthenticator.UserAuthenticator.ValidatePassword(objModellogin.Password.Trim(), userInfo.Password)) { Session["UserID"] = Convert.ToInt32(userInfo.UserID); Session["UserName"] = userInfo.FullName; if (!userInfo.IsActive || userInfo.IsLocked && userInfo.IsLocked) { return(Json(new { val = 1, result = "User not valid", url = Url.Action("Index", "Home") })); } if (userInfo.IsPasswordAccepted != null && (bool)userInfo.IsPasswordAccepted) { Session["IsLogged"] = true; FormsAuthentication.SetAuthCookie(userInfo.UserID.ToString(), false); var userUrl = dalObj.UserAccessPermissionList(Convert.ToInt32(userInfo.UserID)); Session["userUrlPermission"] = userUrl; return(RedirectToAction("Index", "Home")); } Session["IsLogged"] = true; return(RedirectToAction("ChangePassword", "Home")); } strErrorMsg = "Incorrect User Password!"; } else { strErrorMsg = "Incorrect User Information!"; } } else { strErrorMsg = strExpiryValMsg; } } ViewBag.Msg = strErrorMsg; return(View()); } catch (Exception exception) { return(RedirectToAction("Error", "Home")); } }