I am trying to cache a output controller like I did in ASP.NET MVC 5.
I did that in ASP.NET MVC 5 Controller:
[OutputCache(Duration = 60, VaryByParam = "*", Location = OutputCacheLocation.ServerAndClient)]
Now, I'm trying that in ASP.NET 5 MVC 6:
Controller Attribute:
[ResponseCache(CacheProfileName = "TestCache")]
In my Startup.cs:
//Caching
services.Configure<MvcOptions>(options => options.CacheProfiles.Add("TestCache", new CacheProfile()
{
Duration = 3600,
Location = ResponseCacheLocation.Any,
VaryByHeader = "*"
}));
I have added a breakpoint in my TestController, but the breakboint is fired everytime.
How can I fix it?
You should use new attributes of MVC Actions described here. For example
corresponds to
It places HTTP header
in the corresponding HTTP response.
If you prefer to use caching profiles, you will find the corresponding information about the usage in the same article (see here).