I have ActionResult Login
that validates my user and saves the data in a Session, if everything is ok, redirect to ActionResult BPAC
:
[HttpPost]
public ActionResult Login(string pUsuario, string pSenha)
{
oUsuario = modelOff.usuarios.SingleOrDefault(p => p.usuario1 == pUsuario && p.senha == pSenha);
if (oUsuario == null)
{
return RedirectToAction("ErroLogin");
}
else
{
Session["usuario"] = oUsuario;
return RedirectToAction("BPAC");
}
}
The ActionResult BPAC
needs a string
called ibge
to work, and I have to get it in the Session
created previously, but the system does not recognize it.
public ActionResult BPAC()
{
if (Session["usuario"] == null)
{
return RedirectToAction("ErroLogin");
}
string ibge = Session["usuario"].ibge; //<<<<< ERRO AQUI
List<Estabelecimento> listaEstabelecimento = new Estabelecimento().listaEstabelecimento(ibge);
return View(listaEstabelecimento);
}
This line I marked is not recognized by the system. How do I use Session
here in my Controller
?