1
I am trying to display a message according to the return of my method, which is a Task<ActionResult>
, but when I call the TempData
, she’s coming empty, where I’m erring?
@section scripts {
<script type="text/javascript">
$("#button-submit").click(function ()
{
alert('@(TempData["CurrentTab"])');
})
</script>
}
these are the returns of my form
[HttpPost]
public async Task<ActionResult> Index(ApiLServico.ContatoObject _user, string cpf,
string ddd, string telefone, int Niveis)
TempData["Message"] = res;
{...condições...}
return View();
}
TempData["Message"] = "Ocorreu um erro";
return RedirectToAction("Index", "Home");
}
catch (Exception ex) { TempData["Message"] = ex.ToString();
return RedirectToAction("Index", "Home"); }
}
TempData["Message"] = "Por favor preencha todos os campos" ;
return RedirectToAction("Index", "Home");
How can I make it work properly by passing the messages I want?