Update your startup.csto have this inside ConfigureServices:
services.AddCaching();
, IMemoryCache:
public class HomeController : Controller
{
private IMemoryCache cache;
public HomeController(IMemoryCache cache)
{
this.cache = cache;
}
, :
public IActionResult Index()
{
var myList = new List<string>();
myList.Add("lorem");
this.cache.Set("MyKey", myList, new MemoryCacheEntryOptions());
return View();
}
public IActionResult About()
{
ViewData["Message"] = "Your application description page.";
var myList= this.cache.Get("MyKey");
return View();
}
MemoryCache dotnet.today.