asp.net mvc 3 - Overriding Caching defined in Global ActionFilter -
my aim have global nocacheactionfilter attribute (registered in global.asax.cs ) disables caching default.
then i'd add more fine-grained control in on needed actions of controllers i'd add caching attribute should override 1 defined in global nocacheactionfilter.
my approach
in nocacheactionfilter
public override void onactionexcecuting(actionexecutingcontext filtercontext) { //disable caching httpcachepolicybase cache = filtercontext.httpcontext.response.cache; cache.setcacheability(httpcacheability.nocache); ... } and in caching attribute ...
public override void onactionexecuted(actionexecutedcontext filtercontext) { //add caching ... cache.setcacheability(httpcacheability.public); ... } note difference between onactionexecuting , onactionexecuted, should invoked 1 after other, order should granted.
however, apparently does not work. suggestions?? have feeling miss trivial thing...
just guess. after changing cache object of filtercontext call method of base filter class?
... base.onactionexecuting(filtercontext); } and
... base.onactionexecuted(filtercontext); }
Comments
Post a Comment