我有服務器使用WriteFile的你下載過該文件的一個5MB的PDF給我下載15兆字節,其中作爲的TransmitFile給出正確的文件大小爲5Mb ...C#Response.WriteFile VS Response.TransmitFile文件大小問題
是這是由於某種解壓縮到服務器上的writeFile內存?只是不知道是否有人看到發生同樣的事情...
(PS只注意到它,因爲我們去IIS7?)
代碼是...
if (File.Exists(filepath))
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.AddHeader("content-disposition","attachment;filename=\""+Path.GetFileName(filepath)+"\"");
HttpContext.Current.Response.AddHeader("content-length", new FileInfo(filepath).Length.ToString());
//HttpContext.Current.Response.WriteFile(filepath);
HttpContext.Current.Response.TransmitFile(filepath);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Close();
}
我剛剛有同樣的錯誤。 IIS上的壓縮設置不會影響它。 – geofftnz 2011-11-03 01:06:31