Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi ,
Everyone has given the solution while uploading the file.

But i need a solution "While Downloading a file i need to blockUI and once the download gets completed in need to unblockUI "

Platform - ASP.net, MVC
Posted

1 solution

If you handle the file downloading yourself in server side code by writing chunk by chunk to the response stream, then you'll know when the file had finished downloading. You would simply have to connect the FileStream to the response stream, send data chunk by chunk, and redirecting after complete. This can be inside your popup window.

C#
Response.ContentType = "application/octet-stream";
Response.AppendHeader("content-disposition", "attachment; filename=bob.mp3");
Response.AppendHeader("content-length", "123456789");


Make sure you check Response.IsClientConnected when writing out to the response stream.

or

follow the link for similar solution
File Download in ASP.NET and Tracking the Status of Success/Failure of Download[^]
 
Share this answer
 
v2
Comments
Member 12118526 6-Nov-15 3:09am    
What Im doing here is will generate a file Content and then i will save in the folder
then im downloading the file from the folder.
$("#test").click(function (){
$.blockUI();
$.ajax({
type: "POST",
url: '../../Controller/GenerateFile',
data: "",
success: function (result) {
// debugger
window.location.href = '../../Controller/DownloadIFile?file=' + result;
$.unblockUI();
}
});
public ActionResult DownloadFile(string file)
{
string fullPath = file;
return File(fullPath, "application/vnd.ms-excel", "FileName");
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900