简体   繁体   English

IE的大文件下载问题

[英]IE download issue with large file

I am building application in the Asp.net MVC and I have some features to download zip files of more than 50 MB. 我正在Asp.net MVC中构建应用程序,并且具有一些功能可以下载超过50 MB的zip文件。 All is working fine but in IE10,11 version zip file download more than 40MB is giving error and not downloading. 一切正常,但在IE10,11版本的zip文件中,超过40MB的下载错误并没有下载。 It's giving error like download was interrupted . 出现错误,例如下载中断 For your information I am using IONIC.DLL for zipping the file. 供您参考,我正在使用IONIC.DLL压缩文件。 It's working good in all other browsers. 在所有其他浏览器中都运行良好。 I am attaching the sample code as well with this. 我还附有示例代码。

        Response.Clear();
        Response.BufferOutput = false;  // for large files
        Response.ContentType = "application/zip";
        Response.AddHeader("content-disposition", "filename=Documents.zip");
        Response.AddHeader("Content-Length", "632620");

        using (var zip = new ZipFile())
        {
            foreach (var file in files)
            {
                if (!file.Contains(":")) continue;
                var filename = file.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries)[0];
                var fileUrl = Server.MapPath(string.Format("~/Uploads/{0}MyLib/{1}", Test, filename));

                //zipping current file
                zip.AddFile(fileUrl, "Document");
            }    
            zip.Save(Response.OutputStream);
        }

I am posting my answer. 我正在发布我的答案。 After trying all the things I removed code line of Response.Close() from the end the method. 尝试了所有事情之后,我从方法的最后删除了Response.Close()代码行。 Reason was very simple I was not storing Zipped file to any other location on server so meanwhile it will be stored in Response object and when Response.Close() will be executed big size files will be not downloaded yet. 原因很简单,我没有将压缩文件存储到服务器上的任何其他位置,因此与此同时,该文件将存储在Response对象中,并且在执行Response.Close()时,尚未下载大文件。 So it will give error like Download was inturrupted. 因此,它将给出错误消息,例如下载已被破坏。 Thanks @Yeldar and @Oguz for your kind help. 感谢@Yeldar和@Oguz的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM