Question: How do you solve: "InvalidOperationException: The 'Microsoft.AspNetCore.Mvc.ViewFeatures.Infrastructure.DefaultTempDataSerializer' cannot serialize an object of type 'System.Collections.Generic.List`1"
Login to See the Rest of the Answer
Answer: In order to work with TempData, you need to Serialize the Data object into a string first then store it into the TempData["MyObject"], when you need to retrieve the object from the TempData["MyObject"] you simply need to Deserialize the String into an object again.
See code below:
TempData["My"] = JsonSerializer.Serialize(MyObjectInstance);
MyObject my = JsonSerializer.Deserialize(TempData["My"].ToString())