Error on render report

1 Answer 252 Views
.NET Core .NET Framework CrossSection General Discussions Rendering Report Viewer - Angular Report Viewer - HTML5 Report Viewer - MVC Security
Mohanraj
Top achievements
Rank 1
Mohanraj asked on 17 Oct 2022, 03:51 PM | edited on 18 Oct 2022, 11:05 AM

While rendering report got Error like this Error loading the report viewer's templates. (trvTemplateUrl = 'https://abcdf.com/api/reports/resources/templates/telerikReportViewerTemplate-16.0.22.225.html/').  when i try this same telerik reporting from other domain it's working only this domain it gave this error. and network it shows like CORS error. we don't know where to allow all the domain address.       In Asp.net we have this config to enable CORS          



  services.AddCors(c =>
            {
                c.AddPolicy("AllowOrigin", options => options.AllowAnyOrigin().AllowAnyHeader().WithExposedHeaders("X-total-count")); 
                c.AddPolicy("ReportingRestPolicy", corsOptions => corsOptions.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
            });



            app.UseCors("ReportingRestPolicy");
And We noticed that if i try to run domain1 with chrome and domain2 with Edge. both domains are working.  In same browser which domain i run first that works. If i try to run next domain it gives error.

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 20 Oct 2022, 08:28 AM

Hello Mohanraj,

The error indicates that the viewer's template with the particular version 16.0.22.225 cannot be downloaded.

Is it possible that the REST Service is with a different Reporting version? Note that all Telerik Reporting resources that interact should match in version to work as expected.

Can you send us FiddlerJam sessions recorded from the working and non-working domains for comparison?

Regards,
Todor
Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
Mohanraj
Top achievements
Rank 1
commented on 21 Oct 2022, 07:51 AM

Hello Todor,   

i have attached the fiddler Jam redorded link. Please check and let me knowDomain -1  and Domain -2

Todor
Telerik team
commented on 26 Oct 2022, 07:59 AM

Hi Mohanraj,

Thank you for the FiddlerJam sessions. Indeed, they demonstrate that you use the same Reporting version on both domains, and https://alpha4a-test.sdms2.com/V2/ fails with the specified error. Based on the Version request, it seems that the service is responsive on https://alpha4-api.payschools.com/v2/api/reports which is used by both clients.

I tested using the same service that returned the Version and Formats as expected. Unfortunately, the rest of the requests required authorization and my attempts failed.

I compared the Version requests from both domains and there wasn't any difference except for the origin and referer domains, which was expected.

Is it possible for the issue to be due to the browser cache? Can you test in incognito mode of the same browser?

Which viewer do you use? Is the issue reproducible with the pure Html5 Viewer?

Unfortunately, the console error is too general and doesn't let me troubleshoot further.

Can you send us a project we may test with?

Mohanraj
Top achievements
Rank 1
commented on 26 Oct 2022, 08:58 AM

Even incognito also same problem. this happended only on same browser if i use two domain in different tabs. if i check domain-1 in chrome and domain-2 firefox both the report rendered without issue. 
Todor
Telerik team
commented on 31 Oct 2022, 08:29 AM

Hello Mohanraj,

We inspected the available information again with a developer. It seems that the request for the template never gets performed.

Here is the code of our Html5 Viewer that catches the exception and displays the error message:

templateCache.load(options.templateUrl, svcApiUrl, client)
                                .catch(function () {
                                    $placeholder.text(utils.stringFormat(sr.errorLoadingTemplates, [utils.escapeHtml(options.templateUrl)]));
                                    return Promise.reject();
                                })
                                .then(function (result) {
                                    templates = result.templates;
                                    scripts = result.scripts;
                                    return loadStyleSheets(result.styleSheets);
                                })
                                .then(start);

and this is the code of the above function load:

load: function (url, serviceUrl, client) {
                var p = cache[url];
                if (!p) {
                    cache[url] = p = client.get(url)
                        .then(function (html) {
                            var templates = {};
                            var styleSheets = [];
                            var scripts = [];
                            var baseUri = utils.rtrim(serviceUrl, '\\/') + '/';
                            html = utils.replaceAll(html, '{service}/', baseUri);
                            html = utils.replaceAll(html, '{service}', baseUri);
                            var viewerTemplate =
                                $('<div></div>').html(html);
                            utils.each(viewerTemplate.find('template'), function (index, e) {
                                var $e = $(e);
                                templates[$e.attr('id')] = utils.trim($e.html(), "\n \t");
                            });
                            utils.each(viewerTemplate.find('link'), function (index, e) {
                                styleSheets.push(utils.trim(e.outerHTML, "\n \t"));
                            });
                            // Remove any duplicates leaving only the last occurrence to take effect
                            styleSheets = utils.filterUniqueLastOccurance(styleSheets);
                            utils.each(viewerTemplate.find('script'), function (index, e) {
                                scripts.push(utils.trim(e.innerHTML, "\n \t"));
                            });
                            return {
                                templates: templates,
                                styleSheets: styleSheets,
                                scripts: scripts
                            };
                        });
                }
                return p;
            }

We think that the problem occurs in the line cache[url] = p = client.get(url) when executing the function client.get(url). It throws, our code catches the exception and displays the error message.

Unfortunately, we cannot say why the browser throws an exception when executing this function on the second tab only. I suggest stepping through the code of the function client.get(url) while debugging in the browser to see what is the exact problem.
Mohanraj
Top achievements
Rank 1
commented on 31 Oct 2022, 08:40 AM

Hello Todor,  we used tr-viewer, we didn't use the cache[url] = p = client.get(url)
<tr-viewer #reportViewer
                  [containerStyle]="viewerContainerStyle"
                  [reportServer]="reportServerUrl"
                  [reportSource]="reportSource"
                  [viewMode]="'INTERACTIVE'"
                  [scaleMode]="'SPECIFIC'"
                  [scale]="1.15"
                  [pageMode]="'SINGLE_PAGE'"
                  [sendEmail]="emailData"
                  [keepClientAlive]="'true'"
                  [renderingBegin]="renderReport">
                  </tr-viewer>

Todor
Telerik team
commented on 03 Nov 2022, 08:15 AM

Hi Mohanraj,

Please, note that the Angular Report Viewer is a wrapper of our jQuery Html5 Viewer. The latter calls the function, which throws.

Unfortunately, we cannot reproduce the issue locally, and you need to debug it in the browser to gather more details on the exception.

Tags
.NET Core .NET Framework CrossSection General Discussions Rendering Report Viewer - Angular Report Viewer - HTML5 Report Viewer - MVC Security
Asked by
Mohanraj
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or