Question File Download in asp.net

onizuka

New member
Joined
May 21, 2009
Messages
1
Programming Experience
Beginner
Hello experts,

I tried to implement file download for asp.net.
In my download function:
I inserted this,
' Source of this method: DownloadFile - Send a file to the client browser
VB.NET:
            ' clear the current output content from the buffer
            Response.Clear()
            ' add the header that specifies the default filename for the Download/
            ' SaveAs dialog
            Response.AddHeader("Content-Disposition", "attachment; filename=" & Filename)
            ' add the header that specifies the file size, so that the browser
            ' can show the download progress
            Response.AddHeader("Content-Length", Contents.Length.ToString)
            ' specify that the response is a stream that cannot be read by the
            ' client and must be downloaded
            Response.ContentType = "application/octet-stream"
            ' send the file stream to the client
            Response.OutputStream.Write(Contents, 0, Contents.Length)
            ' stop the execution of this page
            Response.End()

Somehow when i run, it will prompt the message "property evaluation failed' after the line 'response.end()'. however if i press 'f5' to continue, the correct file will still be able to download.

Any advice why it is complaining the error on response.end function? and if i comment out this line,i will have no error message, still able to download file as normal.

Another problem that i have is, the download page. download.aspx will not close automatically..any advice?

thanks,
onizuka
 
Back
Top