Output cache in MVC

2019-07-12 02:39发布

问题:

How can I get the dropbox items in cache, in MVC?

I have tried the following, but it calls the page function each time.

What could be the issue or the right way to do it?

Please suggest.

[OutputCache(Duration = 10, Location = System.Web.UI.OutputCacheLocation.Server,
      NoStore = true, Order = 0)]
    public IEnumerable<SelectListItem> GetRegions()
    {

回答1:

You should have it in your controller on those actions there