473,385 Members | 1,610 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,385 software developers and data experts.

How to download large (400MB +) files from an asp.net page???

Hi,

I am trying to find a working solution for download of large files (400-800
MB)...
But this seems almost impossible to find a working example.

I have tried Response.Transmitfile, this works for some people…but in my
case the server reset the connection after approx. 20 minutes and sometimes
after
7-8 minutes…the download speed is however very good 400MB takes about 10
minutes to download.

I have also tried the code below, this solution also resets the connection
after 4-5 MB…and the download goes very slow approx. 55 kb/s…

Please does anyone have any ideas or proposals?
Is it possible to download via FTP?
Is it possible to use resume of broken downloads somehow?
Are there any components on the market that can achieve this?

'Download the selected file

Response.Buffer = False
Server.ScriptTimeout = 100
Dim FullPath As String = Server.MapPath(currentPath + StrFileName)
Dim DownloadFileInfo As New FileInfo(FullPath)
Dim Name = DownloadFileInfo.Name
Dim Ext = DownloadFileInfo.Extension
Dim stream = New System.IO.FileStream(FullPath, System.IO.FileMode.Open,
System.IO.FileAccess.Read, System.IO.FileShare.Read)
Dim StrFileType As String = ""
If Not IsDBNull(Ext) Then
Ext = LCase(Ext)
End If
Select Case Ext
Case ".exe"
'Exe file
StrFileType = "application/octet-stream"
Case ".zip"
'Zip file
StrFileType = "application/x-zip-compressed"
Case ".pdf"
'Pdf file
StrFileType = "application/pdf"
Case ".doc"
'MS Word
StrFileType = "Application/msword"
Case ".dll"
'Dll file
StrFileType = "application/x-msdownload"
Case ".html", ".htm"
'Html file
StrFileType = "text/HTML"
Case ".txt"
'Txt file
StrFileType = "text/plain"
Case ".jpeg", ".jpg"
'Jpg picture
StrFileType = "image/JPEG"
Case Else
StrFileType = "application/octet-stream"
End Select
'Clear the headers
Response.ClearHeaders()
Response.ClearContent()
Response.Clear()
'Add the download headers
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Disposition", "attachment; filename=" + Name)
If StrFileType <> "" Then
Response.ContentType = StrFileType
End If
Response.AddHeader("Content-Length", DownloadFileInfo.Length)
Dim buffer(10000) As Byte
Dim length As Long
'Total bytes to read:
Dim bytesToRead As Long = stream.Length
Dim UserHasDownload As Boolean = False
Try
'Read the bytes from the stream in small portions.
While (bytesToRead > 0)
'Make sure the client is still connected.
If (Response.IsClientConnected) Then
'Read the data into the buffer and write into the output stream.
length = Int(stream.Read(buffer, 0, 10000))
Response.OutputStream.Write(buffer, 0, length)
Response.Flush()
'We have already read some bytes.. need to read only the remaining.
bytesToRead = bytesToRead - length
UserHasDownload = True
Else
'Get out of the loop, if user is not connected anymore..
bytesToRead = -1
UserHasDownload = False
End If
End While
Catch
'An error occurred..
Finally
End Try
stream.Close()
Jul 22 '05 #1
5 3343
"There was no way for you to know it, but this is a classic asp newsgroup.
While you may be lucky enough to find a dotnet-knowledgeable person here who
can answer your question, you can eliminate the luck factor by posting your
question to a group where those dotnet-knowledgeable people hang out. I
suggest microsoft.public.dotnet.framework.aspnet."

Ray at work

Response courtesy of Bob Barrows

"Thomas Andersson" <Th*************@discussions.microsoft.com> wrote in
message news:58**********************************@microsof t.com...
Hi,

I am trying to find a working solution for download of large files (400-800 MB)...
But this seems almost impossible to find a working example.

I have tried Response.Transmitfile, this works for some peoplebut in my
case the server reset the connection after approx. 20 minutes and sometimes after
7-8 minutesthe download speed is however very good 400MB takes about 10
minutes to download.

I have also tried the code below, this solution also resets the connection
after 4-5 MBand the download goes very slow approx. 55 kb/s

Please does anyone have any ideas or proposals?
Is it possible to download via FTP?
Is it possible to use resume of broken downloads somehow?
Are there any components on the market that can achieve this?

'Download the selected file

Jul 22 '05 #2
Hi Ray,

Thank you for letting me know this.
The reason that I posted here was that I have already posted my question on
the microsoft.public.dotnet.framework.aspnet forum.
Bu no one has answered two of my earlier questions on that forum.
So I was hoping that someone here could answer…
/Thomas ;o)

"Ray Costanzo [MVP]" wrote:
"There was no way for you to know it, but this is a classic asp newsgroup.
While you may be lucky enough to find a dotnet-knowledgeable person here who
can answer your question, you can eliminate the luck factor by posting your
question to a group where those dotnet-knowledgeable people hang out. I
suggest microsoft.public.dotnet.framework.aspnet."¹

Ray at work

¹ Response courtesy of Bob Barrows

"Thomas Andersson" <Th*************@discussions.microsoft.com> wrote in
message news:58**********************************@microsof t.com...
Hi,

I am trying to find a working solution for download of large files

(400-800
MB)...
But this seems almost impossible to find a working example.

I have tried Response.Transmitfile, this works for some people…but in my
case the server reset the connection after approx. 20 minutes and

sometimes
after
7-8 minutes…the download speed is however very good 400MB takes about 10
minutes to download.

I have also tried the code below, this solution also resets the connection
after 4-5 MB…and the download goes very slow approx. 55 kb/s…

Please does anyone have any ideas or proposals?
Is it possible to download via FTP?
Is it possible to use resume of broken downloads somehow?
Are there any components on the market that can achieve this?

'Download the selected file


Jul 22 '05 #3
=?Utf-8?B?VGhvbWFzIEFuZGVyc3Nvbg==?= wrote on 12 jul 2005 in
microsoft.public.inetserver.asp.general:
Hi Ray,

Thank you for letting me know this.
The reason that I posted here was that I have already posted my
question on the microsoft.public.dotnet.framework.aspnet forum.
Bu no one has answered two of my earlier questions on that forum.
So I was hoping that someone here could answer


There was no way for Ray to know that. ;-}

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 22 '05 #4
Hi Evertjan,

Well that is true...
I was only answering, I did not mean to be unpleasant ;-)

"Evertjan." wrote:
=?Utf-8?B?VGhvbWFzIEFuZGVyc3Nvbg==?= wrote on 12 jul 2005 in
microsoft.public.inetserver.asp.general:
Hi Ray,

Thank you for letting me know this.
The reason that I posted here was that I have already posted my
question on the microsoft.public.dotnet.framework.aspnet forum.
Bu no one has answered two of my earlier questions on that forum.
So I was hoping that someone here could answerƒ Ý


There was no way for Ray to know that. ;-}

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 22 '05 #5
=?Utf-8?B?VGhvbWFzIEFuZGVyc3Nvbg==?= wrote on 12 jul 2005 in
microsoft.public.inetserver.asp.general:
=?Utf-8?B?VGhvbWFzIEFuZGVyc3Nvbg==?= wrote on 12 jul 2005 in
microsoft.public.inetserver.asp.general:
> Hi Ray,
>
> Thank you for letting me know this.
> The reason that I posted here was that I have already posted my
> question on the microsoft.public.dotnet.framework.aspnet forum.
> Bu no one has answered two of my earlier questions on that forum.
> So I was hoping that someone here could answerƒ Ý
>


There was no way for Ray to know that. ;-}


Well that is true...
I was only answering, I did not mean to be unpleasant ;-)


It wasn't ment to be reproachful.

I just liked to echo the "no way to know".

[However, in general, if you you try a second NG with the same Q,
better say so to prevent multiposting flames.]
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 22 '05 #6

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

Similar topics

4
by: Alexander Gilman Carver | last post by:
I have written a pair of scripts that are supposed to work together to display an index of files and then, upon the user choosing the files (with checkboxes on an HTML form submitted to itself),...
12
by: Swede | last post by:
Hello, I am posting this rather lengthy description here in hope of getting at least some insight into a problem that is really hurting my business, since I have come to the conclusion that my...
3
by: Pete Davis | last post by:
I'm having trouble dealing with bitmaps larger than about 10,000 pixels in either direction. I've tried using DrawImage and DrawImageUnscaled, but both give me out of memory errors. In my...
1
by: Al Cadalzo | last post by:
I have a web page that allows a user to download data by clicking on a link button. I then use Aspose.Excel (v1.0.3705) to generate the file for download and then I call the "Save" method on the...
12
by: Jerry Camel | last post by:
I thought I had finally figured out how to control the downloads from my page. I was having issues with large files, but after much research I came up with the following code. The download seems to...
0
by: Thomas Andersson | last post by:
Hi, I am trying to find a working solution for download of large files (400-800 MB)... But this seems almost impossible to find a working example. I have tried Response.Transmitfile, this...
6
by: Jatin | last post by:
Hey Guys I have a web application that allows users to download files. But the files are not hosted on the webserver. The files are stored on external servers and are referenced by a URL/URI....
35
by: rbt | last post by:
I've been doing some file system benchmarking. In the process, I need to create a large file to copy around to various drives. I'm creating the file like this: fd = file('large_file.bin', 'wb')...
3
by: Gargoyle | last post by:
I am curious to know if any research has been conducted regarding the efficiency of having a single (large) .js file downloaded for a webpage compared to several smaller .js files. For example...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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,...
0
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...

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.