I have a controller action something similar to the below, TempData was initialized by my framework. I've noticed that TempData doesn't clear out the value once it is read as shown in the action "EmployeeUnderAge".
When does TempData clears the data that has been read?
public class HomeController : Controller
{
public ActionResult Index(int iD)
{
var employeeAge = (int)TempData["Age"];
RouteData.Values.Add("Age", employeeAge);
return RedirectToAction("EmployeeUnderAge");
}
public ActionResult EmployeeUnderAge(int employeeAge)
{
var stillInTempData = (employeeAge == ((int) TempData["Age"]));
return (stillInTempData) ? View("Index") : View("Error");
}
}