Answers for "tempdata serializer cannot erorr"

C#
0

tempdata serializer cannot erorr

//TempData uses Session, which itself uses IDistributedCache. IDistributedCache doesn't have the capability to accept objects or to serialize objects. As a result, you need to do this yourself, i.e.:

TempData["PopupMessages"] = JsonConvert.SerializeObject(_popupMessages);
//Then, of course, after redirecting, you'll need to deserialize it back into the object you need:

ViewData["PopupMessages"] = JsonConvert.DeserializeObject<List<PopupMessage>>(TempData["PopupMessages"]);
Posted by: Guest on December-06-2021

C# Answers by Framework

Browse Popular Code Answers by Language