473,396 Members | 1,768 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Big Files and Downlaod using asp.net

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.

Nov 22 '05 #1
1 1232
Does someone have this issue and can help me?
"Liensun" <to**@titi.fr> a écrit dans le message de news:
#G**************@TK2MSFTNGP10.phx.gbl...
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.

Nov 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: delu | last post by:
Can anybody teach me how to write a code using asp, so that i can downlaod file from server to a fixed folder on local computer? Best regards
0
by: Liensun | last post by:
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...
5
by: Brian | last post by:
I need to import data from 720 csv files into an Access database so I can do some editing prior to loading into a SQL Server. These files came from data output from a mainframe on a monthly basis....
11
by: ambika | last post by:
Iam just trying to know "c". And I have a small doubt about these header files. The header files just contain the declaration part...Where is the definition for these declarations written??And how...
14
by: Mick | last post by:
I wrote a C# program that interfaces with a data vendor over the web using an API they supplied and their examples in C#. Now I have another data vendor's API and example that I want to add to...
24
by: Henrik Steffen | last post by:
hello all, on my master-db-server i'm running postgres 7.4.1, and I have got two slave-servers running postgres 7.4.2 running the following query on the master-server (7.4.1) delivers: ...
18
by: UJ | last post by:
Folks, We provide custom content for our customers. Currently we put the files on our server and people have a program we provide that will download the files. These files are usually SWF, HTML or...
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
1
by: janakarathinam | last post by:
i am new in perl.how to downlaod the multiple files or create new directory for stored in downloaded files
5
by: nagmvs | last post by:
Hello, Can anyone tell me how can i create a button in asp and link to download files from some folder one by one Simultaneously? I wrote some code to download one file,i don't no...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.