我正在 c# 2010 的 asp.net 中开发项目。我正在尝试以 .zip 格式下载 mp3 文件。即使大小在 80 到 150 MB 之间,它也可以在本地 PC 中正常工作。它也适用于实时服务器,而 .zip 文件大小介于两者之间,10 to 20 MB但现在我已经上传了介于两者之间的文件,80 to 150 MB它不起作用并且仅在加载页面时不会给出任何错误。页面正在加载可能是因为我在web.config文件中设置了最大超时。
下载代码
if (File.Exists(virtualPath))
{
    FileInfo file = new FileInfo(virtualPath);
    Response.Clear();
    Response.ClearHeaders();
    Response.ClearContent();
    Response.ContentType = "application/zip";
    Response.AddHeader("content-disposition", "attachment;filename=\"" + Path.GetFileName(AlbumName) + "\"");
    Response.AppendHeader("content-length", file.Length.ToString());
    Response.WriteFile(virtualPath);
    //Response.End();
    HttpContext.Current.ApplicationInstance.CompleteRequest();
}
网页配置
<system.web>
      <customErrors mode="Off"></customErrors>
      <compilation debug="true" targetFramework="4.0" />
      <httpRuntime maxRequestLength="2000000000" executionTimeout="999999"/>
</system.web>
<system.webServer>
   <security>
       <requestFiltering>
                <requestLimits maxAllowedContentLength="2000000000" />
       </requestFiltering>
   </security>
   <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
不知道是什么原因。请帮我解决这个错误。如果您有其他解决方案,那就太好了。
编辑
if (File.Exists(virtualPath))
{
    FileInfo file = new FileInfo(virtualPath);
    Response.Clear();
    Response.ClearHeaders();
    Response.ClearContent();
    Response.ContentType = "application/zip";
    Response.AddHeader("content-disposition", "attachment;filename=\"" + Path.GetFileName(AlbumName) + "\"");
    Response.AppendHeader("content-length", file.Length.ToString());
    Response.Buffer = false; 
    Response.TransmitFile(virtualPath);
    //Response.WriteFile(virtualPath);
    //Response.End();
    HttpContext.Current.ApplicationInstance.CompleteRequest();
}
谢谢