In my Controller
, I have a ActionResult
responsible for logging in the user:
[HttpPost]
public ActionResult Valida(string pUsuario, string pSenha)
{
oUsuario = modelOff.usuarios.SingleOrDefault(p => p.usuario1 == pUsuario && p.senha == pSenha);
if (oUsuario == null)
{
Session["usuario"] = "Senha ou usuário incorretos";
return RedirectToAction("Index");
}
else
{
Session["usuario"] = oUsuario;
return RedirectToAction("BPAC");
}
}
In this line: Session["usuario"] = oUsuario;
I inform that in my session I have stored an object of type Usuario
.
How do I show some property of it in View
? I tried like this: @Session["usuario"].usuario1
but it was not. I received the error below:
Compiler Error Message: CS1061: 'object' does not contain a definition for 'user1' and no extension method 'user1' accepting a first argument of type 'object' could be found an assembly reference?)