我有一个返回文件的 IHttpHandler。当响应流被压缩时,要么自动使用 Telerik RadCompression,要么使用显式设置过滤器
context.Response.Filter = new GZipStream(context.Response.Filter, CompressionMode.Compress);
返回给浏览器的响应是正确的,但在响应的末尾是一些 HTML。HTML 包含异常:
[HttpException(0x80004005):响应过滤器的使用无效] System.Web.HttpResponseStreamFilterSink.VerifyState() +3928894 System.Web.HttpResponseStreamFilterSink.Write(Byte[] buffer, Int32 offset, Int32 count) +28 System.IO.Compression.DeflateStream.Dispose(布尔处理)+363 System.IO.Stream.Close() +28 System.IO.Compression.GZipStream.Dispose(布尔处理)+63 System.IO.Stream.Close() +28 System.IO.Compression.DeflateStream.Dispose(布尔处理)+595 System.IO.Stream.Close() +28 System.IO.Compression.GZipStream.Dispose(布尔处理)+63 System.IO.Stream.Close() +28 System.Web.HttpWriter.FilterIntegrated(布尔 finalFiltering,IIS7WorkerRequest WR)+754 System.Web.HttpResponse.FilterOutput() +121 System.Web.CallFilterExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +174
如果我确保响应未压缩,则响应不包含异常。
那是怎么回事?