I have an <input type="hidden" id="pipo" name="pipo" value /> in the layout.cshtml.
In a method of my controller, I set TempData["pipo"] = "xyz"; and then return RedirectToAction(nameof(aView));.
When aView is rendered, the input "pipo" has "xyz" as value.
But when in another method, I set TempData["pipo"] = "xyz" but in place of a return RedirectionToAction I have a return View("aView"), the pipo input does not have a value.
I tried making a
return RedirectToAction("aView")
in place of
return View("aView")
in that case the input have a value "xyz". Maybe I lost something in the way that values from TempData goes to an <input> or maybe there is something that RedirectToAction does that View() does not.
Temporarily, I'm doing 2 loads, with a RedirectToAction when I need it, but there should be a way to not doing that.
Temp data can be used to set a property. But how are you expecting that value to set the ? send your input value to your controller method values and then from that value assign it your tempdata variable.
Like: