0
我在使AppendHeader正常工作時遇到問題,如果我也在使用授權過濾器。我爲我的AJAX操作使用了ActionFilter,這些操作應用了Expires,Last-Modified,Cache-Control和Pragma(雖然在測試時我已經嘗試在操作方法本身中包含它,而且結果沒有變化)。ASP.net AppendHeader在ASP MVC中不工作
如果我沒有授權過濾器,那麼標頭工作正常。一旦我添加過濾器,我嘗試添加的標題就會被刪除。
的頭我想補充
Response.AppendHeader("Expires", "Sun, 19 Nov 1978 05:00:00 GMT"); Response.AppendHeader("Last-Modified", String.Format("{0:r}", DateTime.Now)); Response.AppendHeader("Cache-Control", "no-store, no-cache, must-revalidate"); Response.AppendHeader("Cache-Control", "post-check=0, pre-check=0"); Response.AppendHeader("Pragma", "no-cache");
從正確的頁面標題的例子:
Server ASP.NET Development Server/9.0.0.0 Date Mon, 14 Jun 2010 17:22:24 GMT X-AspNet-Version 2.0.50727 X-AspNetMvc-Version 2.0 Pragma no-cache Expires Sun, 19 Nov 1978 05:00:00 GMT Last-Modified Mon, 14 Jun 2010 18:22:24 GMT Cache-Control no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Content-Type text/html; charset=utf-8 Content-Length 352 Connection Close
而且從一個不正確的頁面:
Server ASP.NET Development Server/9.0.0.0 Date Mon, 14 Jun 2010 17:27:34 GMT X-AspNet-Version 2.0.50727 X-AspNetMvc-Version 2.0 Pragma no-cache, no-cache Cache-Control private, s-maxage=0 Content-Type text/html; charset=utf-8 Content-Length 4937 Connection Close
它的工作,但爲什麼用一個授權屬性覆蓋我使用的標題,當它工作正常沒有它? – Chao 2010-06-15 08:49:05
@潮看到我的編輯 – Gregoire 2010-06-15 13:30:09