【问题标题】:File download fails for files over 64MB超过 64MB 的文件下载失败
【发布时间】:2010-12-10 08:02:06
【问题描述】:

我有一个允许安全 (ssl) 文件上传和下载的网站。该站点在装有 IIS 6.0 的 Window 2003 服务器上运行; asp.net 2.

使用此代码时:

 protected void StartDownLoad(string filename)
    {
        Response.Clear();
        if(filename.EndsWith("zip"))
            Response.ContentType = "application/zip";
        else
            Response.ContentType = "application/msword";

        string path = "C:\\Inetpub\\sites\\testsite\\secureDocs\\" + filename;
        Response.WriteFile(path);
        string headDesc = "inline;filename=" + filename;

        Response.AddHeader("Content-Disposition", headDesc);
        Response.End();
    }

在我的测试中,一个 62MB 的文件下载没有任何问题 - 一个 65MB 的文件似乎开始下载,然后立即停止。 http 错误日志有四个条目,每个条目都显示“Connection_Dropped”。如果我从文件夹中删除权限并通过 https url 直接访问该文件,我可以下载超过 65MB 的文件,因此这似乎不是 IIS 问题。是否有限制响应写入的 asp.net 设置?是 IIS 的问题吗?有没有人遇到过这个?有什么解决办法吗?

【问题讨论】:

    标签: asp.net iis-6 download


    【解决方案1】:

    你可以试试

    Response.TransmitFile(path) 
    

    而不是

    Response.WriteFile(path)
    

    TransmitFile() 不缓冲文件。

    再见。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-04
      • 1970-01-01
      • 2021-03-01
      • 2016-02-14
      • 1970-01-01
      相关资源
      最近更新 更多