public ActionResult DoLogin(User u) { UserBusinessLayer userBL = new UserBusinessLayer(); if (userBL.IsValidUser(u)) { FormsAuthentication.SetAuthCookie(u.UserName, false); Session["UserName"] = u.UserName; Session["UserId"] = u.Id; Session["Roles"] = userBL.GetRoles(u.UserName); //MoodlePrincipal moodlePrincipal = new MoodlePrincipal(u.UserName, u.Password); //moodlePrincipal.RoleList = new ArrayList(userBL.GetRoles(u.UserName).Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)); //HttpContext.User = moodlePrincipal; return(RedirectToAction("Index", "Student")); } else { ModelState.AddModelError("CredentialError", "Invalid Username or Password"); return(View("Login")); } }