Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> 電腦軟體教學 >> 伺服器技術 >> 關於伺服器

解決 IIS 啟用 Gzip 壓縮導致 OpenFlashChart 在 IE6 顯示「IO Error #2032」問題

編輯:關於伺服器

問題現象

同一套 .NET 程式部署在兩台伺服器,一台正常顯示 OpenFlashChart 圖表,另一台僅在 IE6 顯示 「IO Error #2032」,Firefox/IE7+ 正常。

IE6 顯示 IO Error #2032

IE6 下 OpenFlashChart 載入失敗 IO Error #2032

正常顯示的圖表

正常環境下圖表正確渲染

根因分析

問題伺服器啟用了 IIS Gzip 動態/靜態壓縮,且回應標頭包含 Cache-Control: no-cache。IE6 對「壓縮內容 + no-cache」組合處理有缺陷:解壓縮後嘗試快取卻發現 no-cache,導致資料流中斷,Flash 外掛接收到空資料流拋出 #2032。

解決方案:調整回應標頭 Cache-Control 指令

在輸出 OpenFlashChart 資料的頁面 (如 Chart.aspx、Chart.ashx) 的 Page_Load 或 ProcessRequest 中,移除單純 Response.CacheControl = "no-cache",改用完整指令組合:

Response.Clear();
// Response.CacheControl = "no-cache";  // 單行 no-cache 在 IE6+Gzip 下失效
// 使用完整指令組合,明確禁用快取且相容壓縮
Response.AppendHeader("Cache-Control", "no-cache, no-store, must-revalidate, max-age=-1");
Response.Write(chart.ToString()); // 輸出 OpenFlashChart XML/JSON 資料流
Response.End();

原理解析

  • no-store:禁止任何快取 (含記憶體/磁碟),解決 IE6 壓縮後快取衝突。
  • must-revalidate:強制驗證,確保不使用過期內容。
  • max-age=-1:明確標示已過期。
  • 組合指令讓 IE6 正確處理壓縮資料流,不再嘗試快取導致中斷。

驗證與補充

  1. 修改部署後,清除 IE6 快取 (工具 → 網際網路選項 → 刪除檔案),重新整理頁面,圖表正常顯示。
  2. 其他瀏覽器 (Firefox、IE7+、Chrome) 原本正常,修改後仍正常。
  3. 若網站全域需 Gzip,建議在 Global.asax Application_BeginRequest 針對圖表輸出路徑 (*.ashx/Chart*) 統一加上此標頭。

延伸:IIS 7+ 動態壓縮設定建議

  • <urlCompression doDynamicCompression="true" doStaticCompression="true" />
  • 動態壓縮建議排除 Flash/圖表輸出路徑:
    <add mimeType="application/x-shockwave-flash" enabled="false" /> (在 <dynamicTypes> 中)。
Copyright © Windows教程網 All Rights Reserved