Progress® Telerik® Reporting R3 2017

How To: Add Telerik Reporting REST Web API to Web Application

In this case the Web API will be hosted on top of the classic ASP.NET hosting infrastructure, supported by the IIS (Internet Information Services) server. The REST service setup can be done either by using the Telerik Reporting REST Service project template or manually, as explained below.

Using the REST Service Project Template

In Visual Studio open the Add New Project dialog and select Telerik Reporting REST Service project template, which appears when selecting Reporting category in the left pane. This will add a new project in your solution that contains all the necessary files and packages to host the Telerik Reporting REST service instance.

The project has a preconfigured implementation of reports controller that uses the "~\Reports" path for its reports resolver. This directory is not automatically created and needs to be created or the path to be modified prior to running the project.

Manually configuring Telerik.Reporting REST Service on IIS

To host and configure the Telerik.Reporting REST Service on IIS follow the steps below:

  1. On Visual Studio, create the hosting project. That might be one of the following project templates: ASP.NET Empty Web Application, ASP.NET Web Forms Application, ASP.NET MVC 4 Web Application;

  2. (Only for Empty Web Application / Web Forms Application) Install the Microsoft.AspNet.WebApi.WebHost 4.0.30506 NuGet package. Besides the necessary assemblies this will add the necessary handlers for version 4.0.30506 to the Web.config:

    <handlers>
          <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
          <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
          <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
          <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
          <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
          <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
        </handlers>
    Important note Important

    The Reporting REST WebAPI Service is built against WebAPI 1. In case you have to use newer version of Microsoft.AspNet.WebApi.WebHost (e.g. WebAPI 2) you have to redirect the System.Web.Http and System.Net.Http.Formatting to their newer version. To do this, add the following bindingRedirects to your web.config and replace 5.1.0.0 with the exact version:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Http" culture="neutral" publicKeyToken="31bf3856ad364e35"/>
            <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="5.1.0.0"/>
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Net.Http.Formatting" culture="neutral" publicKeyToken="31bf3856ad364e35"/>
            <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="5.1.0.0"/>
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>

    Visual Studio NuGet Package Manager can add the required binding redirects automatically, if you update NuGet packages through it.

  3. Make sure that the project have the following assembly references:

    • Newtonsoft.Json.dll

    • System.Web.Http.dll

    • System.Web.Http.WebHost.dll

    • System.Net.Http.dll

    • System.Net.Http.Formatting.dll

  4. Implement the reports controller;

  5. (Only for Empty Web Application) Add new item "Global Application Class";

  6. Invoke RegisterRoutes(HttpConfiguration) in the Global.Application_Start (Global.asax) method:

    protected void Application_Start()
    {
        ReportsControllerConfiguration.RegisterRoutes(GlobalConfiguration.Configuration);
  7. Run the application.

  8. To verify whether the service works correctly you can make a request for the available document formats using the following URL:

    http://localhost:[portnumber]/api/reports/formats

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

See Also

Other Resources