1 Answers
- TempData is a dictionary object derived from the TempDataDictionary class.
- TempData is used to pass data from the current request to a subsequent request, in other words in the case of redirection.
- The life of a TempData is very short and it retains its value for a short period of time.
- It requires typecasting for complex data type as I’ve used in my example:
- @foreach (var item in (List<MVCSample.Models.EmpRegistration>)TempData[“EmployeeRegistration”])
- You can retain its value using the Keep method for subsequent requests.