This is a migrated thread and some comments may be shown as answers.

Reporting self hosting

9 Answers 185 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Laz
Top achievements
Rank 1
Laz asked on 14 May 2019, 11:16 AM

Cannot self host telerik rest service as the ReportsController uses the HttpContext which is not available when self hosting

var appPath = HttpContext.Current.Server.MapPath("~/");             

var reportsPath = Path.Combine(appPath, "Reports");

what is the recommended work around

Thanks

9 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 17 May 2019, 07:48 AM
Hi Laz,

The code that uses HttpContext just specifies the folder where the Standalone designer reports would be looked for by the ReportFileResolver. If your application needs this resolver you may use an alternative way to specify the folder where the reports are held.

Regards,
Todor
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Laz
Top achievements
Rank 1
answered on 17 May 2019, 08:11 AM

Hi Todor

All my reports are in a library that is referenced by the web api, it seems I do not need the resolver at all do I?

regards Laz

0
Todor
Telerik team
answered on 17 May 2019, 11:57 AM
Hi Laz,

If all the reports are type reports (i.e. CS/VB classes) you probably need only the ReportTypeResolver and can remove the ReportFileResolver, hence the code using the HttpContext. The resolver of the service may be defined just as :

var resolver = new ReportTypeResolver();


Regards,
Todor
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Laz
Top achievements
Rank 1
answered on 17 May 2019, 01:06 PM

Hi 

Thanks for your help I tried the type resolver as you suggested I get the following error

Error loading the report viewer's templates. (trvTemplateUrl = 'http://localhost:8000/api/reports/resources/templates/telerikReportViewerTemplate-html').

I don't believe my application needs a resolver all my project are in class library project referenced by the web api project, in fact the web api does not have a reports folder at all

Yet it seems to work under IIS

Regards Laz

 

0
Laz
Top achievements
Rank 1
answered on 20 May 2019, 03:36 PM

Hi Todor

I have made progress by adding  ReportsControllerConfiguration.RegisterRoutes(config); to the windows service host.

I am using as you suggested

  var resolver = new ReportTypeResolver();

            //Setup the ReportServiceConfiguration
            ConfigurationInstance = new ReportServiceConfiguration
                                    {
                                        HostAppId = "Html5App", Storage = new FileStorage(), ReportResolver = resolver

                                        // ReportSharingTimeout = 0,
                                        // ClientSessionTimeout = 15,
                                    };

now I have 

Unable to get report parameters.
Report 'Reporting.Library.ReportCatalog.ReportCatalog%2C%20Reporting.Library%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20%20PublicKeyToken%3Dnull' cannot be resolved.

Please help



0
Todor
Telerik team
answered on 22 May 2019, 09:58 AM
Hi Laz,

The error message states that the class ReportCatalog in the namespace Reporting.Library.ReportCatalog in the Reporting.Library assembly cannot be found. My assumption is that this type has been assigned as reportSource->report of the Html5 Report Viewer, i.e. "Reporting.Library.ReportCatalog.ReportCatalog, Reporting.Library, Version=1.0.0.0, Culture=neutral,  PublicKeyToken=null". This assembly should be accessible by the Telerik Reporting REST Service where the Reporting engine is running. So, make sure that this assembly is deployed with the REST Service.

Regards,
Todor
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Laz
Top achievements
Rank 1
answered on 22 May 2019, 01:11 PM

Hi Todor,

But if I switch to IIS hosting it works. it is just self hosting where the problem occurs. and the library project is referenced by the API as well as the the host project  (I know this not needed but just in case)

Any idea?

0
Todor
Telerik team
answered on 27 May 2019, 08:48 AM
Hello Laz,

I tested to setup a Self hosted Telerik Reporting REST Service in a console application as described in the How To: Self Host Telerik Reporting REST Web API article. After enabling CORS the test service resolved successfully TRDP and CS reports (e.g. our demo reports). I have attached the project.

The ConsoleApp1 is where the service is self-hosted. Note that before running the project it will be necessary to execute the following command in the command prompt (run as Administrator) :

"netsh http add urlacl url=http://+:8080/ user=everyone"

The WebAppliation1 project hosts the Html5 Report Viewer, and the CSharp.ReportLibrary project is our demo reports project containing just the BarcodesReport. The TRDP version of the same report is in the ConsoleApp1->Reports folder and can also be displayed in the viewer.

You may test the sample and try to adjust your project accordingly.

Regards,
Todor
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Laz
Top achievements
Rank 1
answered on 27 May 2019, 01:28 PM

Hi Todor

Thanks for your help, I also resolved the issue the report library also needs to be referenced by the host as well as the web api.

Thanks for your your help I will check out your sample

Tags
General Discussions
Asked by
Laz
Top achievements
Rank 1
Answers by
Todor
Telerik team
Laz
Top achievements
Rank 1
Share this question
or