1
我爲客戶端從我的網站上下載內容(視頻)創建了一個HttpHandler(.ashx)。首先我使用WriteFile方法,我意識到它需要大量內存,然後決定將其更改爲TransmitFile方法。使用Response.TransmitFile時不能多次調用處理程序ashx
但是發生了一件奇怪的事情,我無法再做一次以上的下載。我不得不等待下載完成並啓動其他。
基本上代碼是這樣的:
System.IO.FileInfo file = new System.IO.FileInfo(file_path);
context.Response.Clear();
if (flagH264)
{
context.Response.ContentType = "video/mp4";
}
else
{
context.Response.ContentType = "video/x-ms-wmv";
}
context.Response.AddHeader("Content-Length", file.Length.ToString());
context.Response.AddHeader("Content-Disposition", "attachment; filename=" + name);
//context.Response.WriteFile(file_path.Trim());
context.Response.TransmitFile(file_path.Trim());
context.Response.Flush();
任何人都可以知道這是什麼問題呢?