0
I am creating a small project in Asp.net MVC 5 to train and I am having problems passing a Controller object to the View, is showing some error related to the Where<> method of the LINQ library.
Error:
"The model item inserted in the dictionary is of type'System.Linq.Enumerable+Wherelistiterator`1[Project01.Models.Usuario]', but this dictionary requires an item of type 'Project.Models.Usuario''. "
Action that sends the object to the View:
private static int userId;
public ActionResult Perfil()
{
if (Session["UserEmail"] != null)
{
return View(AllUsers.Where(x => x.UsuarioId == userId));
}
else
{
return RedirectToAction("Default", "Home");
}
}
Object Reference in View:
@model Projeto01.Models.Usuario
NOTE: Remembering that the project does not use Entityframework.
If you need any more information just ask.
Look at the link that was answered on this question https://stackoverflow.com/questions/40373595/the-model-item-passed-into-the-dictionary-is-type-but-this-dictionary-requ/47357343#47357343
– CelzioBR