1

I know I can write a custom ActionFilter for an ASP.NET MVC Controller Action to set headers in the response that will disable caching.

My question is, is there an out-of-the-box ActionFilter in the MVC BCL that already does this? Or must I have to create my own custom one?

core
  • 32,451
  • 45
  • 138
  • 193
  • sry is it a duplicate? http://stackoverflow.com/questions/8786942/disable-caching-on-a-partial-view-in-mvc-3 – Larry May 29 '14 at 16:27

1 Answers1

1

You can use the [OutputCache] filter:

[HttpGet]
[OutputCache(Location = OutputCacheLocation.None, NoStore = true)]
public ActionResult Index()
{
      // ....
      return View();
}

See MSDN

haim770
  • 48,394
  • 7
  • 105
  • 133