升級 MVC 2 後,Response.Clear() 在 View 輸出階段失效(Controller 階段正常)。Kooboo CMS Module 受影響。
public void Clear()
{
if (this.UsingHttpWriter) this._httpWriter.ClearBuffers();
IIS7WorkerRequest wr = this._wr as IIS7WorkerRequest;
if (wr != null) this.ClearNativeResponse(true, false, wr);
}
private bool UsingHttpWriter => (this._httpWriter != null) && (this._writer == this._httpWriter);
條件 UsingHttpWriter 要求 _writer == _httpWriter。MVC 2 View 執行時,_writer 被替換為 HttpWriter 以外的包裝器(如 MvcViewPage 內部 Writer),導致判斷失敗,ClearBuffers 不執行。
除錯截圖確認:
Response.Filter 攔截輸出流。Response.Clear。