Handling an ASP.NET MVC FileResult returned in an (jQuery) Ajax call Handling an ASP.NET MVC FileResult returned in an (jQuery) Ajax call ajax ajax

Handling an ASP.NET MVC FileResult returned in an (jQuery) Ajax call


Problem: I have no Idea what I'm supposed to do with this data to get it to the user.

You shouldn't use AJAX for downloading files for this reason. You could do the following:

  1. The user clicks on the download button
  2. Using javascript you show some progress image informing him that he will have to wait
  3. Using javascript you generate and inject a hidden iframe into the DOM having its src property pointing to the controller action supposed to generate the file
  4. Once the iframe is loaded you could hide the progress image