用ie的下载:一会就出现了:“与服务器的连接重置” 窗口,下载断掉了。
之后系统在本地区 就一段时间访问不了了。
用迅雷下载:可以下载完 ,但是下载下来的文件 打开不了,同样一段时间访问不了系统。
服务器上的excel文件都是正常没问题的文件。
之后系统在本地区 就一段时间访问不了了。
用迅雷下载:可以下载完 ,但是下载下来的文件 打开不了,同样一段时间访问不了系统。
服务器上的excel文件都是正常没问题的文件。
byte[] buffer = new Byte[1048576]; // Length of the file:
int length; // Total bytes to read:
long dataToRead; try
{
// Open the file.
iStream = new System.IO.FileStream(pathname, System.IO.FileMode.Open,
System.IO.FileAccess.Read,System.IO.FileShare.Read);
// Total bytes to read:
dataToRead = iStream.Length; Response.ContentType = "application/x-msdownload";
Response.AddHeader("Content-Disposition", "attachment; filename=" + DownloadFileName); // Read the bytes.
while (dataToRead > 0)
{
// Verify that the client is connected.
if (Response.IsClientConnected)
{
// Read the data in buffer.
length = iStream.Read(buffer, 0, 1048576); // Write the data to the current output stream.
Response.OutputStream.Write(buffer, 0, length); // Flush the data to the HTML output.
Response.Flush(); buffer= new Byte[1048576];
dataToRead = dataToRead - length;
}
else
{
//prevent infinite loop if user disconnects
dataToRead = -1;
}
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (iStream != null)
{
//Close the file.
iStream.Close();
}
}
Respons.TransmitFile(path);
直接传输文件到客户端,很少占用服务器内存,不用缓存,据说可传2GB的文件,缺点不支持断点续传。
还是会出现 “与服务器的连接被重置” 的问题。
接着就有一段时间http访问不了系统了(这个问题可能是电信的) ,但是ping命令可以ping 通 。