爲我目前的項目,它是必要的,以生成動態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