Last week I blogged about the usage of TempData in ASP.NET Core. By default the data is stored until it's read in another request.
After you have read the data through the indexer the data will be removed from the TempData dictionary:
But what if you want to keep(no pun intended) the data around longer? This is possible through the usage of the Peek() and Keep() methods. With the Peek() method you can read the data without deleting it. With the Keep() method you can mark the data for retention.
Nice trick!