By using the clearReportCache
and destroy
method, you can clear the server side cache. You have to use this method when closing report viewer and switching to another report within your application.
<div id="reportviewer"></div>
<script>
var isSubmit = true;
$(document.body).bind('submit', $.proxy(this.formSubmit, this));
function formSubmit(args)
{
isSubmit = false;
}
window.onbeforeunload = function () {
if (isSubmit) {
var reportviewerObj = $("#reportviewer").data("boldReportViewer");
reportviewerObj.clearReportCache();
reportviewerObj.destroy();
}
isSubmit = true;
};
</script>
In the PostReportAction
method, you have to collect the GC
with ClearCache
as shown in the following code sample.
public object PostReportAction([FromBody] Dictionary<string, object> jsonArray)
{
bool isclearcache = false;
if (jsonArray != null && jsonArray.ContainsKey("reportAction") && jsonArray["reportAction"].ToString() == "ClearCache")
{
isclearcache = true;
}
var reportresult = ReportHelper.ProcessReport(jsonArray, this, this._cache);
if (isclearcache)
{
GC.Collect(); isclearcache = false;
}
return reportresult;
}