New to Telerik Reporting? Download free 30-day trial

Adding Telerik Reporting REST ServiceStack to Web Application

This article describes the steps required to host the Telerik Reporting ServiceStack REST Service implementation on top of the classic ASP.NET hosting infrastructure supported by the IIS (Internet Information Services) server.

Telerik Reporting ServiceStack assembly requires V3 of the ServiceStack framework.

How to host the ServiceStack implementation of Telerik Reporting REST service in IIS:

  1. Create a new ASP.NET Empty Web Application.
  2. Install the ServiceStack NuGet package.
  3. Add references to the following Telerik Reporting assemblies (required):

    • Telerik.Reporting.dll
    • Telerik.Reporting.Services.ServiceStack.dll
  4. Add references to the following Telerik Reporting assemblies (optional):

    • Telerik.Reporting.Cache.Database.dll - only if DatabaseStorage caching mechanism is intended. For more details check Reporting REST Service Storage. The assembly has dependencies on Telerik Data Access which can be checked in the version corresponding Upgrade article;
    • Telerik.Reporting.OpenXmlRendering.dll - depends on Third-Party Dependencies. Required if you need to export in OpenXML formats (DOCX, PPTX, XLSX);
    • Telerik.Reporting.XpsRendering.dll - required if you need to export in XPS format;
    • Telerik.Reporting.Adomd.dll - required if you use CubeDataSource components in reports. The assembly has dependencies on Microsoft.AnalysisServices.AdomdClient.dll v. or above with proper binding redirects;
  5. Create a new class which derives from ReportsHostBase. It could be called ReportsHost for example:

    • Set the ReportServiceConfiguration property. The ReportSourceResolver and Storage configuration settings are required. See the IReportServiceConfiguration interface for more details.

      Here is a sample implementation with the setup:

      public class ReportsHost : Telerik.Reporting.Services.ServiceStack.ReportsHostBase
          public ReportsHost()
              var reportsPath = System.Web.HttpContext.Current.Server.MapPath(@"~\Reports");
              var resolver = new Telerik.Reporting.Services.UriReportSourceResolver(reportsPath)
                  .AddFallbackResolver(new Telerik.Reporting.Services.TypeReportSourceResolver());
              var reportServiceConfiguration = new Telerik.Reporting.Services.ReportServiceConfiguration();
              reportServiceConfiguration.HostAppId = "Application1";
              reportServiceConfiguration.ReportSourceResolver = resolver;
              reportServiceConfiguration.Storage = new Telerik.Reporting.Cache.File.FileStorage();
              this.ReportServiceConfiguration = reportServiceConfiguration;
      Imports Telerik.Reporting.Services
      Public Class ReportsHost
          Inherits Telerik.Reporting.Services.ServiceStack.ReportsHostBase
          Public Sub New()
              Dim reportsPath = System.Web.HttpContext.Current.Server.MapPath("~\Reports")
              Dim resolver = New UriReportSourceResolver(reportsPath) _
                             .AddFallbackResolver(New TypeReportSourceResolver())
              Dim reportServiceConfiguration = New ReportServiceConfiguration()
              reportServiceConfiguration.HostAppId = "Application1"
              reportServiceConfiguration.ReportSourceResolver = resolver
              reportServiceConfiguration.Storage = New Telerik.Reporting.Cache.File.FileStorage()
              Me.ReportServiceConfiguration = reportServiceConfiguration
          End Sub
      End Class

      The provided sample implementation will resolve .TRDP|.TRDX report definitions from the Reports subfolder of the hosting ASP.NET application root. Another option is to reference a reports library and provide report type assembly qualified name from the service clients.

      Do not forget to add all necessary (i.e., referred from the report definitions) connection strings to the application configuration file.

      The above implementation uses the FileStorage method in order to create a cache object instance. All Visual Studio item templates for adding the Reporting REST service use the default FileStorage constructor. The second overload of the FileStorage constructor allows you to specify a folder, and it is recommended for usage in production environment.

    • Alternatively, you may configure the Telerik Reporting REST service from the application configuration file.

      If you prefer this approach, set the value of the ReportServiceConfiguration property to an instance of the ConfigSectionReportServiceConfiguration class.

      public class ReportsHost : Telerik.Reporting.Services.ServiceStack.ReportsHostBase
          public ReportsHost()
              var reportServiceConfiguration = new Telerik.Reporting.Services.ConfigSectionReportServiceConfiguration();
              this.ReportServiceConfiguration = reportServiceConfiguration;
      Public Class ReportsHost
          Inherits Telerik.Reporting.Services.ServiceStack.ReportsHostBase
          Public Sub New()
              Dim reportServiceConfiguration = New Telerik.Reporting.Services.ConfigSectionReportServiceConfiguration()
              Me.ReportServiceConfiguration = reportServiceConfiguration
          End Sub
      End Class

      Then add the restReportService configuration element containing the service settings to the Telerik Reporting Configuration Section.

        <restReportService hostAppId="Application1" reportSharingTimeout="10" clientSessionTimeout="10">
          <reportResolver provider="type" />
          <storage provider="file" />

      For more information see restReportService Element.

  6. Add a new or use the existing Global Application Class global.asax to create and initialize the ServiceStack reports service in the Application_Start method:

    protected void Application_Start()
        new ReportsHost().Init();
    Protected Sub Application_Start()
        Dim reportsHost As New ReportsHost()
    End Sub
  7. Update the configuration file (web.config) to include the following location element:

        <location path="api">
                <compilation debug="true" targetFramework="4.0" />
                    <add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>
                <modules runAllManagedModulesForAllRequests="true"/>
                <validation validateIntegratedModeConfiguration="false"/>
                    <add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
  8. To verify whether the service works correctly you can make a sample request for the available document formats using the following url:


    If the request is successful you should receive the document formats encoded in JSON. For more information see: Get Available Document Formats.

See Also

In this article