asp.net 中兩種不同方式檔案流下載的區別?

我是碼農我怕誰發表於2019-05-11

請問下面兩種方式的區別是?

HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.ContentEncoding = 
	System.Text.Encoding.GetEncoding("utf-8");
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;  
	filename=" + HttpUtility.UrlEncode(downloadFile.Name, System.Text.Encoding.UTF8));
HttpContext.Current.Response.AddHeader("Content-Range", "bytes 0-800/801");
HttpContext.Current.Response.AddHeader("Content-Length", downloadFile.Length.ToString());
HttpContext.Current.Response.TransmitFile(downloadFile.FullName);; 
HttpContext.Current.ApplicationInstance.CompleteRequest();


HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.Buffer = false;
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.AppendHeader("Content-Disposition", 
	"attachement;filename=" + downloadFile.Name);
HttpContext.Current.Response.AppendHeader("Content-Length", 
	downloadFile.Length.ToString());
HttpContext.Current.Response.WriteFile(downloadFile.Name);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();


謝謝各位牛人來噴~

請喊我大龍哥最後編輯於:3年前

此技術問答作者懸賞 10 個80幣

內容均為作者獨立觀點,不代表八零IT人立場,如涉及侵權,請及時告知。

相關文章