Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 3 在MVC 3中忽略OutputCache属性_Asp.net Mvc 3_Caching_Attributes - Fatal编程技术网

Asp.net mvc 3 在MVC 3中忽略OutputCache属性

Asp.net mvc 3 在MVC 3中忽略OutputCache属性,asp.net-mvc-3,caching,attributes,Asp.net Mvc 3,Caching,Attributes,因此,我对IE7不能从MVC3内置的SSL站点下载文件感到不满。为了使IE7能够从SSL站点保存文件,它必须能够缓存 该方法的代码为: [OutputCache(Location = OutputCacheLocation.ServerAndClient, Duration = 20, VaryByParam = "none", NoStore = true )] public override FileContentResult Export(int? id, string

因此,我对IE7不能从MVC3内置的SSL站点下载文件感到不满。为了使IE7能够从SSL站点保存文件,它必须能够缓存

该方法的代码为:

[OutputCache(Location = OutputCacheLocation.ServerAndClient, Duration = 20, VaryByParam = "none", NoStore = true )]
public override FileContentResult Export(int? id, string extra)
{
...
return new FileContentResult(byte[], mimetype);
}
这在IE9、Chrome、Safari和Firefox中都可以使用。 我尝试了VaryByParam、Duration和NoStore的各种设置。当我更改这些设置时,响应标题似乎从未更改

缓存控制:没有缓存,没有存储,必须重新验证

内容处置:附件;filename=PersonalInfo-0209212.xlsx

内容长度:11933

内容类型:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

日期:2012年2月9日星期四18:16:35 GMT

过期:-1

Pragma:没有缓存

服务器:Microsoft IIS/7.5


任何帮助都将不胜感激。

我自己解决了这个问题,但我把它留在那里,以便对其他人有用

问题在于,自定义ActionFilterAttribute正在手动设置缓存信息,因此我在操作上设置的缓存被忽略

为简洁起见,对相关属性进行了修剪:

public class CustomAttributeName: ActionFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        var cache = filterContext.HttpContext.Response.Cache;
        cache.SetExpires(DateTime.UtcNow.AddDays(-1));
        cache.SetValidUntilExpires(false);
        cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
        cache.SetCacheability(HttpCacheability.NoCache);
        cache.SetNoStore();

        base.OnActionExecuting(filterContext);
    }
}

我自己解决了这个问题,但我把它放在那里,以便对其他人有用

问题在于,自定义ActionFilterAttribute正在手动设置缓存信息,因此我在操作上设置的缓存被忽略

为简洁起见,对相关属性进行了修剪:

public class CustomAttributeName: ActionFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        var cache = filterContext.HttpContext.Response.Cache;
        cache.SetExpires(DateTime.UtcNow.AddDays(-1));
        cache.SetValidUntilExpires(false);
        cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
        cache.SetCacheability(HttpCacheability.NoCache);
        cache.SetNoStore();

        base.OnActionExecuting(filterContext);
    }
}

有趣-不知道这里的IEs行为。我现在回避IE的另一个原因是:有趣——我没有意识到IE在这里的行为。我现在回避IE的另一个原因是: