public ActionResult LogIn(UserProfile userprofile) { //connects and checks with the user credentials using (MsInUsEntities msInUsConnection = new MsInUsEntities()) { if (!msInUsConnection.UserProfiles.Any(m => m.Email_Id == userprofile.Email_Id)) { TempData["ErrorLogin"] = "******"; return(RedirectToAction("LogIn", "Account")); } string userpassword = msInUsConnection.UserProfiles.First(m => m.Email_Id == userprofile.Email_Id).Password; if (userpassword != null && userprofile.Password == MyEncryption.DecodeFrom64(userpassword)) { removeUserSession(); Session.Add("UserName", msInUsConnection.UserProfiles.First(m => m.Email_Id == userprofile.Email_Id).FirstName); Session.Add("UserId", msInUsConnection.UserProfiles.First(m => m.Email_Id == userprofile.Email_Id).Id); return(RedirectToAction("Index", "Home")); } } TempData["ErrorLogin"] = "******"; return(RedirectToAction("LogIn", "Account")); }