I want to store a decimal in TempData
. I read in the documentation that it’s not possible to store a decimal, the same way you can store an int for example. I’ve tried every possible combination of storing and retrieving, but the error is always the same – "The 'Microsoft.AspNetCore.Mvc.ViewFeatures.Infrastructure.DefaultTempDataSerializer' cannot serialize an object of type 'System. Decimal'."
.
TempData["PromocodeDiscount"] = 5.00;
decimal discount = 0;
if (TempData["PromocodeDiscount"] != null)
{
discount = Convert.ToDecimal(TempData["PromocodeDiscount"]);
}
1