私はasp.net、c# 2010でプロジェクトを開発しています。その中で、mp3ファイルを.zip形式でダウンロードしようとしています。サイズが 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();
}
Web.config
<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();
}
ありがとう