Search code examples
asp.net-corereporting-servicesreportviewer

Alan Juden .NET Core Report Viewer Working in localhost but not in Production


I am implementing Alan Juden's MVC Report Viewer and running into some issues when I deploy my project to production.

I have set up the report viewer in my .NET Core app and everything is working fine in localhost, but when I deploy to production and try to load the report I get this message in my page where the report should render: Report failed to load, check report parameters...

When I open the browser developer tools under the Network tab I can see the ViewReportPage method is not being found, thus returning a status code of 404

Request URL: https://MYDOMAIN/Report/ViewReportPage/?reportPath=%2FGearUpAlumni%2FAlumniData&page=1&
Request Method: GET
Status Code: 404 Not Found
Remote Address: 
Referrer Policy: no-referrer-when-downgrade

So the issues is not that the report is expecting a parameter (again, works fine in localhost), but that is not finding ViewReportPage method in my ReportController class.

This particular method (ViewReportPage) is being implemented by AlanJuden.MvcReportViewer.ReportController, which is inherited in my controller.

Have anyone ran into a similar issue? or maybe know how to approach this to fix the issue?

Thanks


Solution

  • I got it working. Since my app is deployed to a subdirectory within the domain I needed to change the JavaScript to include the base path.

    So basically from

    $.get("Report/ViewReportPage/[email protected]()&page=" + page + "&" + urlParams)
    

    To

    @{ 
        string pathBase = Context.Request.PathBase;
    }
    ...
    ...
    $.get("@pathBase/Report/ViewReportPage/[email protected]()&page=" + page + "&" + urlParams)
    

    Now the report works fine in localhost and production and is calling the correct URL

    https://MYDOMAIN/SUBDIRECTORY/Report/ViewReportPage/reportPath=%2FGearUpAlumni%2FAlumniData&page=1&