我有服务器使用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