(After upgrading from Q3 2018 to current version) '/api/reports/version' endpoint returns 404, '/api/reports/formats' responds as expected.

1 Answer 255 Views
.NET Framework Report Viewer - HTML5 Upgrade
Henrique
Top achievements
Rank 1
Henrique asked on 09 Apr 2024, 11:38 PM | edited on 09 Apr 2024, 11:53 PM

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.

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 12 Apr 2024, 12:48 PM

Hi Henrique,

I have already replied to your support ticket opened for the same issue. I will summarize my replies with the relevant links also here, so other users experiencing similar problems may benefit from them.

Note that the Get Version request was not available with your older version from 2018. Since the viewer makes this request, I suspect that you have upgraded only the viewer and the service is still with the older Reporting version. Please, try to run the Upgrade Wizard for your .NET Framework projects hosting Telerik Reporting.

When upgrading automatically, please, note that the older and the newer versions should be within 2 years to ensure full success - Upgrading Old Projects to the Latest Telerik Reporting. The reason is the breaking changes we may have introduced. We keep the old code for one to two years before obsoleting it. After this period, the old code may not be recognized by the newer version of the Upgrade Wizard.

I recommend upgrading your Reporting projects at least once per year for a more smooth experience, and to keep up with the product development.

I suggest also changing the code for the 'resolver' to the following one since the Report Resolvers are now obsolete and replaced with ReportSource Resolvers:

IReportSourceResolver resolver = new UriReportSourceResolver(reportsPath)
    .AddFallbackResolver(new TypeReportSourceResolver());
	
configurationInstance = new ReportServiceConfiguration
{
    //...
    ReportSourceResolver = resolver,
    //...
};

Regarding the changes in Reporting, please, check the articles under the Upgrade Documentation section. For example, for the latest release, this is the article 2024 Q1 (18.0.24.305).

Regards,
Todor
Progress Telerik

Stay tuned by visiting our roadmap and feedback portal pages, enjoy a smooth take-off with our Getting Started resources, or visit the free self-paced technical training at https://learn.telerik.com/.
Tags
.NET Framework Report Viewer - HTML5 Upgrade
Asked by
Henrique
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or