为我目前的项目,它是必要的,以生成动态CSS ...ASP.NET MVC:输出缓存问题
所以,我有一个局部视图,作为一个CSS递送...控制器代码看起来像这样:
[OutputCache(CacheProfile = "DetailsCSS")]
public ActionResult DetailsCSS(string version, string id)
{
// Do something with the version and id here.... bla bla
Response.ContentType = "text/css";
return PartialView("_css");
}
输出缓存配置文件看起来像:
<add name="DetailsCSS" duration="360" varyByParam="*" location="Server" varyByContentEncoding="none" varyByHeader="none" />
的问题是:当我使用的OutputCache线([的OutputCache(CacheProfile = “DetailsCSS”)]),响应内容键入“text/h tml“,而不是”文本/ css“...当我删除它,它按预期工作...
因此,对我来说似乎OutputCache不保存我的”ContentType“设置在这里.. 。 有没有办法解决?
感谢
谢谢!!! .. actionfilter实际上做到了! – David 2009-11-19 22:12:01
我更喜欢CSSOutputCacheAttribute版本(请注意,您的示例缺少类名称末尾的属性)。我已经测试过它,它可以工作,并且很高兴看到:)。 – Nashenas 2013-10-24 18:41:41