PC Review


Reply
Thread Tools Rate Thread

Big Files and Downlaod using asp.net

 
 
Liensun
Guest
Posts: n/a
 
      19th May 2004
The application is coded using ASP.net and C#.
A part of the application allows the user to download files. The size of
these files can be up to 80 MB.

It works when the connection bandwidth is high. But in other cases, after a
few minutes, the next message is displayed: "The connection with
server was reset".

Here the code that I use:
private void SendPageToBrowser(string filename)

{
// All mime type supports
StringDictionary MimeTypeList = new StringDictionary();
MimeTypeList[".doc"] = "application/ms-word";
MimeTypeList[".zip"] = "application/zip";
MimeTypeList["*"] = "application/octet-stream";

FileInfo fi = new FileInfo(Server.MapPath(filename));
// Checks also that the file exists before cleaning the response
// in case, it doesn't exist, an exception is raised
string FileLength = fi.Length.ToString();
Response.BufferOutput=true;
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = MimeTypeList[fi.Extension];
if (Response.ContentType == null)
{
Response.ContentType = MimeTypeList["*"];
}
Response.AppendHeader("Content-Disposition","attachment;filename=" +
fi.Name);
Response.AppendHeader("Content-Length", FileLength);
if (fi.Length < LOWER_LIMIT)
{
Response.WriteFile(fi.FullName );
}
else
{
Byte[] Buffer = new Byte[CHUNKSIZE];
FileStream DLFile = fi.OpenRead();
while ((Response.IsClientConnected)
&& (DLFile.Read(Buffer,0,CHUNKSIZE) != 0)
)
{

Response.BinaryWrite(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.



 
Reply With Quote
 
 
 
 
Liensun
Guest
Posts: n/a
 
      24th May 2004
Does someone have this issue and can help me?
"Liensun" <(E-Mail Removed)> a écrit dans le message de news:
#(E-Mail Removed)...
> The application is coded using ASP.net and C#.
> A part of the application allows the user to download files. The size of
> these files can be up to 80 MB.
>
> It works when the connection bandwidth is high. But in other cases, after

a
> few minutes, the next message is displayed: "The connection with
> server was reset".
>
> Here the code that I use:
> private void SendPageToBrowser(string filename)
>
> {
> // All mime type supports
> StringDictionary MimeTypeList = new StringDictionary();
> MimeTypeList[".doc"] = "application/ms-word";
> MimeTypeList[".zip"] = "application/zip";
> MimeTypeList["*"] = "application/octet-stream";
>
> FileInfo fi = new FileInfo(Server.MapPath(filename));
> // Checks also that the file exists before cleaning the response
> // in case, it doesn't exist, an exception is raised
> string FileLength = fi.Length.ToString();
> Response.BufferOutput=true;
> Response.Clear();
> Response.ClearHeaders();
> Response.ClearContent();
> Response.ContentType = MimeTypeList[fi.Extension];
> if (Response.ContentType == null)
> {
> Response.ContentType = MimeTypeList["*"];
> }
> Response.AppendHeader("Content-Disposition","attachment;filename=" +
> fi.Name);
> Response.AppendHeader("Content-Length", FileLength);
> if (fi.Length < LOWER_LIMIT)
> {
> Response.WriteFile(fi.FullName );
> }
> else
> {
> Byte[] Buffer = new Byte[CHUNKSIZE];
> FileStream DLFile = fi.OpenRead();
> while ((Response.IsClientConnected)
> && (DLFile.Read(Buffer,0,CHUNKSIZE) != 0)
> )
> {
>
> Response.BinaryWrite(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.
>
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IE won't downlaod files via Activex Ray Dawson Windows Vista General Discussion 2 15th Apr 2008 06:57 PM
Excel dissapeared cannot downlaod any excel files =?Utf-8?B?Y2I=?= Windows XP Help 4 7th Jan 2007 05:26 PM
SP1 downlaod =?Utf-8?B?UGF0cmljaWE=?= Windows XP General 2 5th Nov 2004 05:33 PM
xp pro able to downlaod from I>E =?Utf-8?B?bmlvZw==?= Windows XP Internet Explorer 1 27th May 2004 06:53 PM
downlaod templates .cil files???? Valerie Microsoft Word Document Management 1 26th Nov 2003 06:46 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:53 AM.