How to let a ASP.NET page know when a file is ready for download from the server

后端 未结 2 1969
南旧
南旧 2021-01-07 11:01

I\'m maintaining a legacy VB.Net Webforms App and I\'ve got a strange issue after adding one section.

This is this code in the aspx page which shows the giphy.gif w

2条回答
  •  醉梦人生
    2021-01-07 11:40

    You are downloading a file (contacts.csv) the UI is never updated because the server can only send one type of response at a time (a file or a html page), so the image will remain visible after download.

    To fix this either open the download in a new browser window.

    Download CSV
    
    Download CSV
    

    If the download must come after a PostBack then the above solution will not work. A possible solution would be to just hide the image after the average download time of the file.

    function ShowProgress() {
    
        //rest of code
    
        setTimeout(function () {
            loading.hide();
        }, 2000);
    }
    

提交回复
热议问题