I am working on a Web project and I implement Sessions for the user login that changes the view depending on the role of the user, but I have the problem that the view changes when it is a single user of all there is, I made tests and the users do exist in my data context, but as I said, only the view changes when it is a specific user, when I try to send data from another user, the error appears. image.
var user = db.User.Where(u => u.UserName.Equals(obj.UserName) &&
u.Password.Equals(obj.Password)).FirstOrDefault();
if(user != null){
Session["UsuarioId"] = use.UsuarioId.ToString();
Session["UserName"] = use.UserName.ToString();
return RedirectToAction("LoggedIn");
}
else{
ModelState.AddModelError("","Invalid UserName or Password");
}