2010-04-07 76 views
1

我需要設置http頭來禁用ie(7-8)緩存(它會干擾我的ajax功能)。 我試着插入碼到我的Site.Master的頭部沒有結果 -如何在asp.net中設置httpheaders mvc

<META HTTP-EQUIV="Pragma" 
CONTENT="no-cache"> <META 
HTTP-EQUIV="Expires" CONTENT="-1"> 

如何和我在哪裏可以設置HTTP頭? 還是你有一個更好的解決方案,即ie緩存問題。

關於。

回答

1

嘗試:

[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")] 

該屬性,置於控制器類,禁用高速緩存。因爲我不需要在我的應用程序緩存,我把它放在我的BaseController類:

[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")] 
public abstract class BaseController : Controller 
{ 

這裏是關於OutputCacheAttribute很好的說明:Improving Performance with Output Caching

+0

謝謝,工作完美 – Gidon 2010-04-12 20:53:15