Hey!
I have been using Telerik's Reporting and UI for MVC (version Q3 2018) for years without issues. I have just renewed my license and upgraded to the most recent release, both reporting and MVC. A lot has changed and lots of stuff got broken after the upgrade. I have been correcting it for the last weeks (it's a big project).
But Telerik Reporting is giving me the most headaches. After the upgrade, all pages with reports stopped working. I had met every requirement, but were still receiving "Cannot access the Reporting REST service. (serviceUrl = '/api/reports'). Make sure the service address is correct and enable CORS if needed. (https://enable-cors.org)".
I tested the endpoint '/api/reports/formats', and it failed with some internal errors. I then removed the section <Telerik.Reporting> from my Web.Config file and now it correctly returns a json it a bunch of formats.
Sadly, when I try to open a page with a report I still get "Canno/t access the Reporting REST service..." error. Looking in the browser's network tab I see a request to '/api/reports/version' with a 404 status. I tried opening it manually and got the same 404 error (please remember that /api/reports/formats is working fine!).
I've spent several hours trying to solve this issue but no luck.
If it helps, here's what's being loaded on the HTML page:
<link href="/Content/bootstrap.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/themes/7.2.0/classic/classic-silver.css" />
<link rel="stylesheet" href="https://unpkg.com/@progress/kendo-font-icons/dist/index.css" />
<script src="/Scripts/jquery-1.9.1.js"></script>
<script src="https://unpkg.com/jszip/dist/jszip.min.js"></script>
<script src="/Scripts/kendo/2024.1.130/pako_deflate.min.js"></script>
<script src="/Scripts/kendo/2024.1.130/kendo.all.min.js"></script>
<script src="/Scripts/kendo/2024.1.130/kendo.aspnetmvc.min.js"></script>
<script src="/Scripts/kendo/2024.1.130/cultures/kendo.culture.pt-BR.min.js"></script>
<script src="/Scripts/kendo/2024.1.130/messages/kendo.messages.pt-BR.min.js"></script>
<script src="/Scripts/jquery.unobtrusive-ajax.min.js"></script>
<script src="/Scripts/modernizr-2.5.3.js"></script>
<script src="/Scripts/bootstrap.min.js"></script>
<script src="/ReportViewer/js/telerikReportViewer.kendo-18.0.24.130.min.js"></script>
<script src="/ReportViewer/js/telerikReportViewer-18.0.24.130.min.js"></script>
<script src="/ReportViewer/js/localization.pt-BR.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#reportViewer1")
.telerik_ReportViewer({
// The URL of the service which will serve reports.
// The URL corresponds to the name of the controller class (ReportsController).
// For more information on how to configure the service please check http://www.telerik.com/help/reporting/telerik-reporting-rest-conception.html.
serviceUrl: "/api/reports",
// The URL for custom report viewer template. The template can be edited -
// new functionalities can be added and unneeded ones can be removed.
// For more information please check http://www.telerik.com/help/reporting/html5-report-viewer-templates.html.
//
//ReportSource - report description
reportSource: {
// The report can be set to a report file name (trdx report definition)
// or CLR type name (report class definition).
report: "Mantic.Core.Web.Reports.CancelledSales.CancelledSalesReport, Mantic.Core.Web.Reports, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
},
// Specifies whether the viewer is in interactive or print preview mode.
// PRINT_PREVIEW - Displays the paginated report as if it is printed on paper. Interactivity is not enabled.
// INTERACTIVE - Displays the report in its original width and height without paging. Additionally interactivity is enabled.
viewMode: telerikReportViewer.ViewModes.PRINT_PREVIEW,
// Sets the scale mode of the viewer.
// Three modes exist currently:
// FIT_PAGE - The whole report will fit on the page (will zoom in or out), regardless of its width and height.
// FIT_PAGE_WIDTH - The report will be zoomed in or out so that the width of the screen and the width of the report match.
// SPECIFIC - Uses the scale to zoom in and out the report.
scaleMode: telerikReportViewer.ScaleModes.FIT_PAGE_WIDTH,
// Zoom in and out the report using the scale
// 1.0 is equal to 100%, i.e. the original size of the report
scale: 1.0,
ready: function () {
//this.refreshReport();
},
});
});
</script>
And Here is my ReportsController:
namespace Mantic.Core.Web.Views.Report.Controllers
{
using System.IO;
using System.Web;
using System.Web.Mvc;
using Telerik.Reporting.Cache.File;
using Telerik.Reporting.Services;
using Telerik.Reporting.Services.WebApi;
//The class name determines the service URL.
//ReportsController class name defines /api/report/ service URL.
public class ReportsController : ReportsControllerBase
{
static ReportServiceConfiguration configurationInstance;
static ReportsController()
{
//This is the folder that contains the report definitions
//In this case this is the Reports folder
var appPath = HttpContext.Current.Server.MapPath("~/");
var reportsPath = Path.Combine(appPath, "Reports");
//Add resolver for trdx/trdp report definitions,
//then add resolver for class report definitions as fallback resolver;
//finally create the resolver and use it in the ReportServiceConfiguration instance.
var resolver = new ReportFileResolver(reportsPath)
.AddFallbackResolver(new ReportTypeResolver());
//Setup the ReportServiceConfiguration
configurationInstance = new ReportServiceConfiguration
{
HostAppId = "Html5App",
Storage = new FileStorage(),
ReportResolver = resolver,
// ReportSharingTimeout = 0,
// ClientSessionTimeout = 15,
};
}
public ReportsController()
{
//Initialize the service configuration
this.ReportServiceConfiguration = configurationInstance;
}
}
}
PS: For upgrading UI for MVC, I've found a guide with breaking changes for each version (that had it) and it made the corrections easier, but I have not found one for the Telerik Reporting.