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
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
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
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
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
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
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
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?
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
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