I have a performance issue where we have a 2 page setup as part of a workflow in a bigger system. This section is dedicated to rendering reports allowing users to chose their own parameters.
Page1.aspx collects parameter information for a report. It takes the information submitted on a form and validates it. If it validates OK, it stores the selections in the DB as XML, then redirects to Page2.aspx with the run id in the query string. Simple enough, performance is great.
Page2.aspx pulls the ID out of the DB and hydrates a Crystal ReportDocument object (taking milliseconds) then we call ExportToHttpStream which then renders the report as a PDF or DOC or XLS download (output format is determined in Page1.aspx). The performance of the ExportToHttpStream method is very poor due to the way our reports are written and DB indexes on the target system. This is outwith my control at the moment but I am promised that they are being worked on.
So the problem is, that when the submit button in Page1.aspx is pressed, the user experiences a very long delay before the download starts. It is then compounded by the user pressing the submit button again thinking there is a problem.
I think what I need to do is have Page1.aspx redirect to Page2.aspx. Page2.aspx should render the master page furniture and a loading div, and the report should render asynchronously somehow in the background before the save dialogue automatically pops up, after this i’d like to change the loading div to a ‘Report generated, click here to go back’.
If this is the best way to achieve this, how can I load a full page, then request the report asynchronously? I’m open to any suggestions here.
Whilst both answers gave me some ground to go out and research in the right direction. My solution included using the
fileDownloadplugin from John Culviner to facilitate a similar solution:jQuery fileDownload by John Culviner
This allowed me the following page structure:
Page1.aspx, gathers and validates parameters for the report and puts them into Oracle.Page2.aspx, whilst passed in the runid (pointer to the parameters in the db) via the query string setup 3 hiddendivs. Loading, Error and Success.The script mentioned above was employed at this point. jQuery firstly sets the loading
divvisible then calls the plugin. The plugin dynamically creates aniframeand downloads the binary (xls/doc/pdf) fromPage3.aspx. It then fires a success callback or failure. The success callback is fired by means of a cookie set at the end of the response inPage3.aspx.I believe the plugin mentioned downloads using a
'text/plain'AJAX call in jQuery avoiding the limitation of there not being an octet-stream equivalent in AJAX.It works, its not the cleanest solution by any means, it doesn’t degrade one bit, but provides the users on our controlled intranet with an extremely responsive and pleasing UI.