Download file before upload

4 posts, 0 answers
  1. Gert Van Meerbergen
    Gert Van Meerbergen avatar
    5 posts
    Member since:
    Sep 2006

    Posted 22 Sep 2015 Link to this post

    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.

  2. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 25 Sep 2015 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Gert Van Meerbergen
    Gert Van Meerbergen avatar
    5 posts
    Member since:
    Sep 2006

    Posted 28 Sep 2015 Link to this post

    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).
  5. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 01 Oct 2015 Link to this post

    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
Back to Top