Search code examples
c#.netreporting

How to fix ReportViewer showing the same report to multiple users in ASP.NET MVC?


I've written a system using ASP.NET MVC that generates various financial reports. Each report is in it's own controller, each controller has its own "Report" Action. The Action Renders a partial view with the report in the ViewBag which it passes to javascript on the front end and puts the rendered element in a JQueryUI dialog.

A user may run a Balance Sheet report then another user may run an Income Statement report, after the first user runs the Balance Sheet Report and instead of seeing the Income Statement, the second user sees the Balance Sheet.

This is the code that returns the report as a JSON object

 //Initialize report and add datasources etc.
 reportViewer.LocalReport.Refresh();
 ViewBag.ReportViewer = reportViewer;

 return Json(JsonResponse.Success(RenderRazorViewToString("PrintVoucher", null)));

Here is the Partial View

@using ReportViewerForMvc;


<div class="col-md-12 col-lg-12 col-sm-12 col-xs-12">
    @Html.ReportViewer(ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer)
</div>

Any advice or guidance would be greatly appreciated!


Solution

  • We ran into the same issue and it seems to be related to a concurrency bug in the ReportViewerForMvc. Stumbled on this old github link which had the information and proposed fix. Hope this helps.

    https://github.com/nrifath2009/ReportViewerForMvc/pull/1