How to stop MVC caching the results of invoking and action method?
Posted
by Trey Carroll
on Stack Overflow
See other posts from Stack Overflow
or by Trey Carroll
Published on 2010-06-03T20:18:06Z
Indexed on
2010/06/03
20:34 UTC
Read the original article
Hit count: 422
caching
|asp.net-mvc-2
I am experiencing a problem with IE caching the results of an action method.
Other articles I found were related to security and the [Authorize] attribute. This problem has nothing to do with security.
This is a very simple "record a vote, grab the average, return the avg and the number of votes" method. The only slightly interesting thing about it is that it is invoked via Ajax and returns a Json object. I believe that it is the Json object that is getting catched.
When I run it from FireFox and watch the XHR traffic with Firebug, everything works perfectly. However, under IE 8 the "throbber" graphic doesn't ever have time to show up and the page elements that display the "new" avg and count that are being injected into the page with jQuery are never different.
I need a way to tell MVC to never cache this action method.
This article seems to address the problem, but I cannot understand it: http://stackoverflow.com/questions/1441467/prevent-caching-of-attributes-in-asp-net-mvc-force-attribute-execution-every-tim
I need a bit more context for the solution to understand how to extend AuthorizationAttribute. Please address your answer as if you were speaking to someone who lacks a deep understanding of MVC even if that means replying with an article on some basics/prerequisites that are required.
Thanks,
Trey Carroll
© Stack Overflow or respective owner