Reputation: 7170
i need to show an asp.net page with a message like "Your download will start soon..." then, i need to send a file with Response.WriteFile(myfile). The problem is that i insert my code into Page_LoadComplete, because i assume asp.net will show and rendere basic html, then in the code there is Response.WriteFile(strFullPath). The problem is that no html is rendered, and the file is transfered correctly ! How can i also show a simple html like "Your download is in progress" ... ?
Thanks
Upvotes: 3
Views: 1209
Reputation: 7797
I would suggest moving your Response.WriteFile(struFullPath) to another page all by itself that does nothing but write out the file. Then on your page that says "Your download will start soon...", use one of these methods to write out a link to the page that does the Response.WriteFile.
If you don't want to follow the link for the methods, it's either:
Put the file link into an iframe and it will download
<iframe src="LINKTOTHEFILEPAGE"></iframe>
You could use some JavaScript and a backup meta refresh tag. Load up your html content as you normally would and inject this into the <head>
.
<script>
setTimeout(function(){window.location='LINKTOTHEFILEPAGE';}, 5000);
</script>
<noscript>
<meta http-equiv="refresh" content="5; url=LINKTOTHEFILEPAGE">
</noscript>
Both of these delay the download by 5 seconds. You can adjust as necessary.
Upvotes: 3