I have a problem with TempData
when refreshing the view.
This controller
assigns a string
to TempData
:
public ActionResult Sucursales(string rfcCompany)
{
model.CuentaUser = CuentaUser;
TempData["RFCCompany"] = rfcCompany;//solo para evitar mandar el rfc por la url nuevamente
return View(model);
}
While in the view Sucursales.cshtml
redirecciono to DetalleSucursal.cshtml
, which the controller has this:
public ActionResult DetalleSucursal(int id, int idEmpresa, string CuentaUser){
ComprobantesModel model = new ComprobantesModel();
model.idEmpresa = idEmpresa;
model.idSucursal = id;
model.CuentaUser = CuentaUser;
ViewBag.RFCCompany = TempData["RFCCompany"] as string;//para mostrar el RFC en algun lugar de la vista
return View(model);
}
I have no problem with the first load of the view, the problem comes when I refresh the view DetalleSucursal.cshtml
the TempData["RFCCompany"]
is loaded in the controller as null
as if it had not been loaded from the controller Sucursales
. How can I prevent the TempData["RFCCompany"]
from becoming null
when refreshing the page DetalleSucursal.cshtml
?