[thelist] .Net: Why are downloads 0 bytes?

Anthony Baratta anthony at baratta.com
Mon Jan 15 11:29:41 CST 2007


OK....

If I read your code correctly, you are not picking up the file from the server hard drive and feeding that back to the browser - youa re just sending headers with the file name.

Now, the other thing with your current code is more of a question - I'm assuming that you are just testing something because it appears you aretrying to send the uploaded file back to the user as a download.  Do I read that correctly?

Anyway - just sending the file path is not enough. You need to grab the file and write it back to the browser - and make sure you use a binary stream if it's a binary file.

-----Original message-----
From: "Casey Crookston" caseyc at IntelliSoftmn.com
Date: Mon, 15 Jan 2007 09:01:04 -0800
To: thelist at lists.evolt.org
Subject: [thelist] .Net:  Why are downloads 0 bytes?

> I am baffled. When implementing a file download script
> (http://www.ondotnet.com/pub/a/dotnet/2002/04/01/asp.html) All the
> downloaded files are 0 bytes.  
> 
>  
> 
> Here's the script:
> 
>  
> 
> 'download file
> 
> Dim root As String = strPath & "Uploads\"
> 
> Dim filepath As String = Request.Params("file")
> 
> If Not filepath Is Nothing Then
> 
> Dim filename As String = Path.GetFileName(filepath)
> 
> Response.Clear()
> 
> Response.ContentType = "application/octet-stream"
> 
> Response.AddHeader("Content-Disposition", "attachment; filename=""" &
> filename & """")
> 
> Response.Flush()
> 
> Response.WriteFile(filepath)
> 
> End If
> 
>  
> 
> ???????????
> 
>  
> 
> Thanks, Casey
> 
> -- 
> 
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip Harvester 
> and archives of thelist go to: http://lists.evolt.org 
> Workers of the Web, evolt ! 
> 



More information about the thelist mailing list