Last post May 05, 2016 01:22 PM by subbiahkk
May 04, 2016 03:00 PM|subbiahkk|LINK
In my web api i have a file download controller. This controller will check a specific folder for file chunk and flush the chunks to the user. It will take some seconds to get the first chunk in the folder. I want to throw the response content header that
is the file name before the first chunk but i cant. Is there a way to flush header first before content so that the user understand file download is in progress.
May 05, 2016 02:26 AM|Yohann Lu|LINK
As far as I know, header and content are together in Response. The Web API doesn't "push" information. So, I think your current thinking is not feasible. You can try other ideas.
1: You can immediately display file download is in progress when the user requests. When receive the file download finished message, you can display the file download finished.
2: You can consider SignalR for this.
SignalR allows bi-directional communication between server and client. Servers can now push content to connected clients instantly as it becomes available.
You can refer to the following steps:
*First you send a GET request to receive the size of the file you're about to download and store it in your client. In fact, you could utilise the Content-Length header here to avoid the extra GET.
*Then download your file, while it's happening, your client can report the download progress by comparing how much of the file it has received against the full size of the file it got from the server
You can learn About ASP.NET SignalR in the below link:
May 05, 2016 01:22 PM|subbiahkk|LINK
Hi Yohann Lu,
Thanks for your response. Planning to show some indicator from client end, as well as will try to understand SignalR also.