csharp ASP.net MVC:完全禁用缓存

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp ASP.net MVC:完全禁用缓存相关的知识,希望对你有一定的参考价值。

This is discouraged though. You should rely on the ASP.net caching mechanisms as described in [this article](http://juristr.com/blog/2012/10/output-caching-in-aspnet-mvc/)
public class NoCacheGlobalActionFilter : ActionFilterAttribute
{
    public override void OnResultExecuting(ResultExecutingContext filterContext)
    {
        //IE: http://support.microsoft.com/kb/316431
        if (!(filterContext.Result is FileResult))
        {
            HttpCachePolicyBase cache = filterContext.HttpContext.Response.Cache;
            cache.SetCacheability(HttpCacheability.NoCache);
        }

        base.OnResultExecuting(filterContext);
    }
}

以上是关于csharp ASP.net MVC:完全禁用缓存的主要内容,如果未能解决你的问题,请参考以下文章

csharp ASP.NET MVC 5表单

csharp asp.net mvc模块属性

csharp ASP.NET MVC WebViewPageExtensions

csharp ASP.NET的助手,ASP.NET MVC应用服务器端测试

csharp ASP.NET MVC和LINQ

csharp ASP.NET MVC - 表单输入数组