简体   繁体   中英

Better user experience for website in asp.net MVC

I have a page that downloads a large HTML file from another domain then serve it to the user. The file is around 100k - 10MB and usually takes about 5min. What was think about doing something like this to make the user experience better.

  • download file
  • if file is not download within 10 seconds then displays a page that tells the user that the file is being downloaded
  • if the server completes the download in 1 second then it will serve the downloaded html

can this be done? do I need to use the async feature?

Updated question: the downloaded file is a html file

In order to provide an 'asynchronous' file download try a trick that Google is using: Create a hidden iframe and set it's source to the file you want to download. You can then still run javascript on your original page while the file is being downloaded through the iframe.

I think you should:

  1. Return an HTML page to the user straight away, to tell them the transfer has started.
  2. Start the download from the other domain in a separate process on your server.
  3. Have the HTML from step 1 repeatedly reload, so you can check if the download has completed already, and possibly give an ETA or update to the user.
  4. Return a link to the user when the initial transfer is complete.

It sounds like you need to use a waiting page that refreshes itself every so often and displays the status of your download. The download can be run on a separate thread using a System.Threading.Task, for instance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM