1
I have a student consultation,
// POST: /Admin/Anuncio
[HttpPost]
public ActionResult Index(Estudante estudante)
{
if (ModelState.IsValid)
{
List<EstudantesEncontrados> list = GetEstudante(GetEstudanteProximo(estudante));
if (list != null)
{
TempData["ListaEstudantesEncontrados"] = list;
return RedirectToAction("Lista", "Busca");
}
else
{
ModelState.AddModelError("", "Erro Ao pesquisar");
}
}
// If we got this far, something failed, redisplay form
return View();
}
if you find students redirects to the list of students found, when I refresh the page in the list of students it gives an error in the view because the Tempdata["Student Listfound"] that sends the MODEL is coming null from the above action, someone could help me?
I wonder if there is any way when it is updated the browser it takes the data that was sent in the form previously.
public ActionResult Lista()
{
ViewBag.Message = "";
if (ModelState.IsValid)
{
if (TempData["ListaEstudantesEncontrados"] != null)
{
var model = TempData["ListaEstudantesEncontrados"] as List<EstudantesEncontrados>;
return View(model); ;
}
else
{
ModelState.AddModelError("", "Erro ao consultar");
return RedirectToAction("Index", "Home"});
}
}else{
return RedirectToAction("Index", "Home");
}
}
Lisbão, I believe that the error ta in the view, please post your view?
– user6026