您可以创建一个自定义的行为过滤为了指示浏览器不缓存页面的结果来设置适当的响应头:
public class DisableCacheAttribute : ActionFilterAttribute
{
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
var cache = filterContext.HttpContext.Response.Cache;
cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
cache.SetNoStore();
cache.SetExpires(DateTime.UtcNow.AddDays(-1));
cache.SetValidUntilExpires(false);
cache.SetCacheability(HttpCacheability.NoCache);
}
}
,然后装饰具有这种属性的控制器操作:
[DisableCache]
public ActionResult PerformPayment()
{
...
}
谢谢你,那正是我所需要的,它完美地工作。我很感激帮助。 – esastincy 2011-05-12 20:59:38