So the Windows/Temp folder is fast filling the disk in my deployment. Each time a report is opened, a number of files are created here. The problem is, of course, probably that I'm not releasing my report objects in my code, as these files can't even be manually deleted without shutting down IIS. Well, fair enough. What I can't figure out is where to release my reports.
I have two pages: one performs a pre-pass of the report object and generates a dynamic page to prompt the user for parameters. This page, I believe, has no problems because the report.Close() command is in line with the code and is the final statement. The second page, however, has the CrystalReportsViewer object and actually displays the report to the user after setting up the parameters correctly. On this page, I can't figure out how/when to call report.Close(). If I do it at the page.Dispose event, there seems to be no affect. If I do it at the page.Close event, the report will load fine, but if you try to go to another page in the report (in the case of multi-page reports) or refresh the data, the report object has already been unloaded and the CrystalReportsViewer won't be able to find the report document. If I wrap my code in one big Try-Catch-Finally (rather than just having a Try-Catch around the file load itself) and place a report.Close() command in the Finally, the Finally is executed before the viewer even loads the report so I get a file not found error.
So where can I unload the report object? What I want is to persist the report via Sessions (which I do) so that as the user moves between pages of the report/refreshes the report will remain loaded, but when the user closes the page or browses to another page, perhaps, I want to close the report and free the resources so that the temp files are deleted. I can post my code if needed... Thanks in advance,
Pont
I have two pages: one performs a pre-pass of the report object and generates a dynamic page to prompt the user for parameters. This page, I believe, has no problems because the report.Close() command is in line with the code and is the final statement. The second page, however, has the CrystalReportsViewer object and actually displays the report to the user after setting up the parameters correctly. On this page, I can't figure out how/when to call report.Close(). If I do it at the page.Dispose event, there seems to be no affect. If I do it at the page.Close event, the report will load fine, but if you try to go to another page in the report (in the case of multi-page reports) or refresh the data, the report object has already been unloaded and the CrystalReportsViewer won't be able to find the report document. If I wrap my code in one big Try-Catch-Finally (rather than just having a Try-Catch around the file load itself) and place a report.Close() command in the Finally, the Finally is executed before the viewer even loads the report so I get a file not found error.
So where can I unload the report object? What I want is to persist the report via Sessions (which I do) so that as the user moves between pages of the report/refreshes the report will remain loaded, but when the user closes the page or browses to another page, perhaps, I want to close the report and free the resources so that the temp files are deleted. I can post my code if needed... Thanks in advance,
Pont