Search code examples
jquerydotnetnukegembox-spreadsheet

GemBox stops the rest of the backend code to function in a DNN module


We have a DNN module which will fetch a Price-list from our ERP system once you have selected the Format that you will like to export it to. We are using GemBox to generate the Excel, CSV or PDF file but the problem we have realized is that the rest of the code stops functioning as soon as it starts to generate the file for download. This means the PostBack stops.

We are using the last section of code from GemBox which will not hard abort the thread: https://gemboxsoftware.deskpro.com/kb/articles/threadabortexception-in-asp-net-application

We made sure that partial rendering is disabled in DotNetNuke.

We then changed the back-end code to fetch a separate .aspx file (not .ascx file) once the code fires to generate the Exel, CSV or PDF file. This prevents the PostBack from stopping to work. This will now generate the download file but I am trying to stop the loading icon from showing. I used RegisterStartupScript which goes to a JQuery function to stop it, but it never fires this RegisterStartupScript even though on the separate file which the code is included in the PageLoad section and the code goes through it when debugging. (Does this mean you can't load separate pages on an DNN module other than the view.ascx file?)

It seems like the Front-End never updates after this Download file has downloaded. Could this be the HTTP Header Response that is breaking the rest of the code?

How can I reset/reload a DNN module page without reloading the entire webpage?

Does this mean I will have to write an Ajax function with some kind of Web Worker function? I would just like to reload the DNN module once the Download file pops up on the browser.


Solution

  • When you are generating a file and responding to the user with that file to download. No other actions or response can be handled be the browser, such as register startup script or otherwise. BUT you can send back a cookie.

    As such, one way to handle this is to trigger some client-side code when they click to download and show your progress indicator, and then check for the existence, or not, of a cookie depending on how you implement. When this changes you can hide the progress.

    The solution is a bit complicated, but this answer shows a great detail on how to do it: