Closed migig closed 9 years ago
I discovered this which answers the question. The info was buried in the comments in the blog, so I didn't see them. Bottom line, unlike normal output caching, this library allows you to place the code in any of the four methods. Just ensure the filter ordering is right.
An actionfilter has four hooks:
OnActionExecuting
,OnActionExecuted
,OnResultExecuting
,OnResultExecuted
. I understand that this library uses the first two.I need to use other actionfilters on my cached action. I usually use
OnActionExecuting
, but the action is cached so such an actionfilter won't be called. So instead I put such code in a donut hole (i.e. child view) and call it from a view. This works but is "messy" and harder to test.So I've been trying to put this kind of stuff into actionfilters which use
OnResultExecuting
andOnResultExecuted
. I noticed that it works most of the time as I expect.What I need to know is this "safe" or will I break something? Can I do whatever I want in these two functions? Including changing headers, setting cookies, redirecting, etc.? I assume the only thing I can't do is change the cached result, but everything else is ok?