This is a migrated thread and some comments may be shown as answers.

Download file before upload

3 Answers 204 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Gert Van Meerbergen
Top achievements
Rank 1
Gert Van Meerbergen asked on 22 Sep 2015, 12:21 PM

We have a page where you can download some files (via a link in a grid) and upload one file. When you first do a download of a file and then try to upload a file, the server side event FileUploaded is not triggered and only the click event of the related post trigger button is going off, but then the UploadedFiles property of the RadAsyncUpload doesn't have the uploaded file. When you click again on the button then the FileUploaded event is triggered.

The code to download the file is the following:

Dim stream As System.IO.MemoryStream = reportResult.ReportStream
response.Clear()
response.ClearHeaders()
Dim filter As IO.Stream = response.Filter
response.Filter = Nothing
response.ContentType = reportResult.Report.Type.MimeType
response.AddHeader("Content-Disposition", "attachment; filename=" & fileName)
If stream.Length > 0 Then stream.WriteTo(response.OutputStream)
response.End()

It seems that something in the download is making the RadAsyncUpload losing some triggers which are reset after the first postback.

3 Answers, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 25 Sep 2015, 07:41 AM
Hi Gert,

I don't understand what you mean. The server FileUploaded event will be fired after you select a file and cause a postback. Can you attach sample?

Thanks.

Regards,
Hristo Valyavicharski
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Gert Van Meerbergen
Top achievements
Rank 1
answered on 28 Sep 2015, 12:14 PM
Check the attached project (VS2013 - rename to zip, because zip is not allowed).
As explained in my first post, when you first click the download link and after that select a file with the RadAsyncUpload control and click on the upload button the FileUploaded event is not triggered. When you click again on the upload button then the FileUploaded event is triggered.
I have used the Telerik.Web.UI.dll and Telerik.Web.UI.Skins.dll from version 2013.2.717.45 (I had to remove them from the zip becuase of the attachment file limit of 2MB).
0
Hristo Valyavicharski
Telerik team
answered on 01 Oct 2015, 12:30 PM
Hi Gert,

I looks like that response clearing breaks the AsyncUpload functionality:
Private Sub Download_Click(sender As Object, e As EventArgs) Handles Download.Click
    Dim data As Byte()
    Dim br As IO.BinaryReader = New IO.BinaryReader(System.IO.File.OpenRead(Server.MapPath("~/DownloadFile.txt")))
    data = br.ReadBytes(br.BaseStream.Length)
    Dim ms As IO.MemoryStream = New IO.MemoryStream(data, 0, data.Length)
    ms.Write(data, 0, data.Length)
    'Response.Clear()
    'Response.ClearHeaders()
    Dim filter As IO.Stream = Response.Filter
    Response.Filter = Nothing
    Response.ContentType = "text/plain"
 
    Response.AddHeader("Content-Disposition", "attachment; filename=DownloadFile.txt")
    If ms.Length > 0 Then ms.WriteTo(Response.OutputStream)
    Response.End()
End Sub

There are two things that you can do:
Regards,
Hristo Valyavicharski
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
AsyncUpload
Asked by
Gert Van Meerbergen
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
Gert Van Meerbergen
Top achievements
Rank 1
Share this question
or