Question

I want to make download page after button click. This page should show some information and then, after some time start downloading file. the best if that would work withouns JavaScript and Ajax. I ave tried with async controller but this not really works like I want.

Was it helpful?

Solution

I can only think of one way to make this happen. Add an HTTP header (refresh) that redirects the browser to the download link after the interval. Since the link will return a response that's an attachment, it shouldn't actually refresh the browser page, but it should begin the download. In the head section of your view add:

<meta http-equiv="refresh" content="30; ,URL=@Model.DownloadURL">

This assumes that your model contains the URL for the download in the DownloadURL model property. It should begin the download after 30 seconds.

As an aside, AJAX might help to get the initial download page shown, but you can't download files via AJAX. That takes a full request since the XMLHttpRequest doesn't handle Content-Disposition: attachment.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top