I know that TempData
has its "life" held until it is used in View
. However, if I do in two different controllers, the same identified TempData
, I'm killing and over writing them.
If the user is using 2 browser tabs, he may issue the wrong message.
So, how do I use TempData
or other functionality to send data from a Controller
to View
, to pass messages, without having the problem with multi tabs. I also did not want to go through URLs.
Supplementary data (Edited)
Code
using (var db = new Conexao())
{
var usuario = db.Usuario.Find(id);
var retorno = EntidadeBaseExt.ValidarRegistro(usuario);
if (retorno != "")
{
TempData["MsgRetornoError"] = retorno;
return RedirectToAction("Index", "Home");
}
return View(usuario);
}
Problem
If the user is using 2 tabs, on tab 1 he looks for id = 1 and on tab 2 he searches for id = 3, and both have an error message.
It may happen that the message in tab 2, writing the message in tab 1, and presenting the wrong information.
In this way I would have to go some way to make sure that tab 1 gets your message and Tab 2 gets your message.
If I do this:
return RedirectToAction("Index", "Home", new { msg = "Teste " + id.ToString() });
The msg field stays in the url and I did not want it.