Search code examples
asp.net-mvcresponseexport-to-excel

MVC control calling thread after export to excel


I have the export to excel working by creating a seperate ActionResult that sets the content type of the response stream header to "application/vnd.ms-excel" and also sets the excel file as a "attachment". Before all this starts, my calling view displays a jquery modal that says "processing...". Since its a seperate UI thread, is it possible to terminate the modal once the excel file stream has reached the client? The only way I can think of is by using a javascript timer, but thats not flexible.


Solution

  • Use javascript to handle the .click of the export button.

    Your window.location points to the route of a FileResult type of action.

    That will open the download dialog, and you can continue with updating the UI. That's a "asynchronous" style file export.

    Quick StackOverflow search found: this