I have a [ResponseCache] attribute on an action method with the default cache Location = ResponseCacheLocation.Any. But in few cases only I want to override this property to ResponseCacheLocation.Client.
Is there a better way to override the attribute in the action method code than using Response.Headers.Add ? (not even sure if it would work)
Using DefaultHttpContext in the unit test I can access to GetTypedHeaders, but I don't have access to this method from the real Response in the controller.
I can confirm that the
[ResponseCache]
attribute can be overridden within the action method in the following way:However, I don't think there's a better way to handle these kind of "exceptions to the rule".