473,586 Members | 2,817 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 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.

Nov 22 '05 #1
1 1240
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 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.

Nov 22 '05 #2

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

Similar topics

1
1390
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
286
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 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:...
5
3409
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. There are 15 files created each month with each file containing specific data. What I started to do is store the files by year and then by month...
11
5572
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 does that get linked to our program when we run it??I would appreciate any helpful info..And I would like to thank you for that in advance -ambika
14
7316
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 my C# program. But this new API is written in Java. They gave me an example source code that uses their API but the actual API looks like it is...
24
2926
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: explain analyze select * from foo where bar like '0101%' and foobar like 'top%';
18
2285
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 JPG files. The problem as I see it - if you know the name of the file, you could download it off the server (currently we are using an HTTP/Get but...
221
367284
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 needs to store entire files, the preferred method is to save the file onto the server’s file-system, and store the physical location of the file in...
1
1582
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
2687
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 how to write the code to download files one by one from specific folder. my code is (I WROTE IN ASP USING VB.NET) <a...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7954
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8215
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3836
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.