I am not able to put progress bar because it is directly redirecting the page and file is downloaded.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Carriage Return (ASCII chr 13) is missing from tex
So many questions (most of them implicit) in a single one!
Do not use AJAX downloading if it is not needed. When you open a file in the browser (
contentDisposition: inline
), simply use a new Tab(/Window). When you download a file (contentDisposition: attachment
), the current page won't be affected. You can find several ways to do this in this answer, for example:Every browser has an inbuilt progress bar that is shown when downloading files:
The browser is not able to draw the progress bar only in the case the length of the file to be downloaded has not been provided. To instruct the browser, you can use the
contentLength
header, that is also directly available in the Stream result:If you want to save bandwidth, then you need to work on your Web Server configuration. This article might help:
If instead you don't care about preventing flooding requests, but only preventing multiple concurrent downloads for a client, you can use a session variable, put at the beginning and removed at the end of your method, checking for its existence at the beginning of your download action. If it exist, you won't download, otherwise, you will:
The good old semaphore.