The application is coded using ASP.net and C#.
A part of the application allows the user to download files. The size of
these field can be up to 80 MB.
It works when the connection bandwidth is high. But in other cases, after a
few minutes, the next messages is displayed: "The connection with
server was reset".
Here the code that I use:
private void SendPageToBrows er(string filename)
{
// All mime type supports
StringDictionar y MimeTypeList = new StringDictionar y();
MimeTypeList[".doc"] = "applicatio n/ms-word";
MimeTypeList[".zip"] = "applicatio n/zip";
MimeTypeList["*"] = "applicatio n/octet-stream";
FileInfo fi = new FileInfo(Server .MapPath(filena me));
// Checks also that the file exists before cleaning the response
// in case, it doesn't exist, an exception is raised
string FileLength = fi.Length.ToStr ing();
Response.Buffer Output=true;
Response.Clear( );
Response.ClearH eaders();
Response.ClearC ontent();
Response.Conten tType = MimeTypeList[fi.Extension];
if (Response.Conte ntType == null)
{
Response.Conten tType = MimeTypeList["*"];
}
Response.Append Header("Content-Disposition","a ttachment;filen ame=" +
fi.Name);
Response.Append Header("Content-Length", FileLength);
if (fi.Length < LOWER_LIMIT)
{
Response.WriteF ile(fi.FullName );
}
else
{
Byte[] Buffer = new Byte[CHUNKSIZE];
FileStream DLFile = fi.OpenRead();
while ((Response.IsCl ientConnected)
&& (DLFile.Read(Bu ffer,0,CHUNKSIZ E) != 0)
)
{
Response.Binary Write(Buffer);
Response.Flush( );
}
DLFile.Close();
}
Response.End();
}
What's wrong in my code or which settings of IIS I have to change?
Any helps will be greatly appreciated.
Olivier.
A part of the application allows the user to download files. The size of
these field can be up to 80 MB.
It works when the connection bandwidth is high. But in other cases, after a
few minutes, the next messages is displayed: "The connection with
server was reset".
Here the code that I use:
private void SendPageToBrows er(string filename)
{
// All mime type supports
StringDictionar y MimeTypeList = new StringDictionar y();
MimeTypeList[".doc"] = "applicatio n/ms-word";
MimeTypeList[".zip"] = "applicatio n/zip";
MimeTypeList["*"] = "applicatio n/octet-stream";
FileInfo fi = new FileInfo(Server .MapPath(filena me));
// Checks also that the file exists before cleaning the response
// in case, it doesn't exist, an exception is raised
string FileLength = fi.Length.ToStr ing();
Response.Buffer Output=true;
Response.Clear( );
Response.ClearH eaders();
Response.ClearC ontent();
Response.Conten tType = MimeTypeList[fi.Extension];
if (Response.Conte ntType == null)
{
Response.Conten tType = MimeTypeList["*"];
}
Response.Append Header("Content-Disposition","a ttachment;filen ame=" +
fi.Name);
Response.Append Header("Content-Length", FileLength);
if (fi.Length < LOWER_LIMIT)
{
Response.WriteF ile(fi.FullName );
}
else
{
Byte[] Buffer = new Byte[CHUNKSIZE];
FileStream DLFile = fi.OpenRead();
while ((Response.IsCl ientConnected)
&& (DLFile.Read(Bu ffer,0,CHUNKSIZ E) != 0)
)
{
Response.Binary Write(Buffer);
Response.Flush( );
}
DLFile.Close();
}
Response.End();
}
What's wrong in my code or which settings of IIS I have to change?
Any helps will be greatly appreciated.
Olivier.
Comment