Does “TempData” preserve data in the next request also?
Ask by Anonymous User
Updated 06 Jun 2023
TempData is a dictionary that is used to store data that needs to be preserved between requests. By default, TempData is cleared after each request. However, there are a few ways to keep data in TempData for the next request.
Code snippet
Code snippet
It is important to note that TempData is not a permanent storage mechanism. It is designed to store data for a short period of time, such as the duration of a single user session. If you need to store data for a longer period of time, you should use a database or a file system.
The “TempData” is available throughout for the current request and in the subsequent request, it’s available depending on whether “TempData” is read or not.
So if “TempData” is once read it will not be available in the subsequent request.