public ActionResult Login(LogonModel logonmodel) { try { if (ModelState.IsValid) { UserBLL Userbll = new UserBLL(); UserModel adminModel = new UserModel { UserName = logonmodel.UserName, Password = DataEncryption.Encrypt(logonmodel.Password, "passKey") }; UserModel objadministrator = Userbll.AdminLogin(adminModel); if (adminModel != null) { Session["UserId"] = objadministrator.AdminId; Session["UserName"] = objadministrator.UserName; Session["RoleId"] = objadministrator.RoleId; Session.Timeout = 120; if (logonmodel.Returnurl != null) { return(Redirect(logonmodel.Returnurl)); } return(RedirectToAction("Dashboard", "MasterData")); } } Session["Error"] = "Invalid User name or Password."; return(View("Index", logonmodel)); } catch (Exception) { Session["Error"] = "Invalid User name or Password."; return(View("Index", logonmodel)); throw; } }