locked
Webforms website progress bar/status to long running webclient process RRS feed

  • Question

  • User1738843376 posted

    Hi,

    I have a Webforms Website project where upon clicking a button, the codebehind starts a connection via WebClient to download a large file as a Byte array.

    I am able to set the WebClient connection as an async task, and can see the progress as i log it to a database log table, but can't seem to find a way to return the progress of the download to the user.

    I was trying with an UpdatePanel and UpdateProgress, but cannot find a way to do it.

    I am also considering returning the progress via SignalR, but cannot also find an example on the internet that actually works with WebForms, as all end up with 'Obsolete' error messages when i attempt to run them.

    I'm bound to the webforms website, and attempting to convert the code from MVC examples has been fruitless.

    Can somebody point me in the right direction?

    Thanks

    Monday, May 10, 2021 4:53 PM

All replies

  • User-939850651 posted

    Hi 0belix,

    According to your description, if you wants to show download progress, have you tried using WebClient.DownloadProgressChanged Event?

    But A passive FTP file transfer will always show a progress percentage of zero, since the server did not send the file size.So you need to change the FTP connection to active by overriding the GetWebRequest(Uri) virtual method:

    internal class MyWebClient : WebClientProtocol
    {
        protected override WebRequest GetWebRequest(Uri address)
        {
            FtpWebRequest req = (FtpWebRequest)base.GetWebRequest(address);
            req.UsePassive = false;
            return req;
        }
    }

    Best regards,

    Xudong Peng

    Tuesday, May 11, 2021 8:19 AM