I am using
TempData["hdn"] = "1";
in controller
If I use this
@{
var hdn = (string)TempData["hdn"];
}
in View, TempData["hdn"]
value in getting null in POST. If I skip this code in view it persists in POST. Why this is happening?
TempData
?TempData
is used to persist things between calls, but is cleared once accessed. (You may want to either pass the value in with a query parameter or your form submission). (See squaredroot.com/2007/12/20/mvc-viewdata-vs-tempdata) – Lanta