Problems with Response.TransmitFile, Response.End and IE

南楼画角 提交于 2019-12-04 11:09:08

Don't use Response.End();

try

Response.TransmitFile(filePath);
Response.End();

in fact, after .NET 2.0, you should use

Response.TransmitFile(filePath);
context.HttpApplication.CompleteRequest();
Jakob Möllås

Since I cannot (yet) add comments, here comes a small note.

Be aware of Response.End() since that method terminates the thread and nothing will be executed after that point. You may want to do a Response.Flush() after TransmitFile() to make sure everything gets sent to the client.

See this question for more information about on Response.End().

Obviously a little late to be useful to the OP, but apparently ZIP files have some problems with MIME types and IIS compression. See the wiki on SharpLibZip:

https://github.com/icsharpcode/SharpZipLib/wiki/Zip-Samples#wiki-anchorMemory

Response.ContentType = "application/zip" ' If the browser is receiving a mangled zipfile, IIS Compression may cause this problem. Some members have found that ' Response.ContentType = "application/octet-stream" has solved this. May be specific to Internet Explorer.

This probably explains why you need to use binary/octet.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!