alanjuden / MvcReportViewer

Custom Report Viewer control to replace MS Report Viewer on MVC projects (also works on .NET Core as a Report Viewer).
MIT License
173 stars 109 forks source link

Parameter validation #62

Closed rono1 closed 5 years ago

rono1 commented 6 years ago

I am looking for a way to make sure that the parameters submitted for a report are valid for the current user. I determined that I could do this if could override the ViewReportPage method in ReportController, but I currently can't. Could you update that to be virtual so I can override it? But if there's a better way to do parameter validation, then I'd be glad to hear that.

rono1 commented 6 years ago

Upon further playing, I found a way to override it even though it's not virtual. Just use the new modifier as in the code below:

    [HttpGet]
    public new JsonResult ViewReportPage(string reportPath, int? page = 0)
    {
      var model = GetReportViewerModel(Request);
      foreach (var item in model.Parameters)
      {
        //handle parameter validation here
      }

      return base.ViewReportPage(reportPath, page);
    }