Progress® Telerik® Reporting R3 2017

ReportsControllerBaseReportServiceConfiguration Property

Gets or sets the configuration of the report service.

Namespace:  Telerik.Reporting.Services.WebApi
Assembly:  Telerik.Reporting.Services.WebApi (in Telerik.Reporting.Services.WebApi.dll)

Syntax

public IReportServiceConfiguration ReportServiceConfiguration { get; set; }

Property Value

Type: IReportServiceConfiguration

Remarks

When inheriting the ReportsControllerBase controller basic configuration is needed. Provide an object implementing the IReportServiceConfiguration in order to configure the report service. This should be done in the controllers' constructor using static object to preserve the configuration between requests or using dependency injection.

Examples

This example shows how to configure WebAPI service using dependency injection.

1. Setup method registering the configuration object in a dependency injection container. The example uses the Unity container.
using System.Web;

public static class WebApiConfig
{
    public static void RegisterDependencies(System.Web.Http.HttpConfiguration config)
    {
        var container = new Microsoft.Practices.Unity.UnityContainer();

        container.RegisterInstance(
            typeof(Telerik.Reporting.Services.IReportServiceConfiguration),
            null,
            CreateReportServiceConfiguration(),
            new Microsoft.Practices.Unity.ContainerControlledLifetimeManager());

        config.DependencyResolver = new UnityResolver(container);
    }

    static Telerik.Reporting.Services.IReportServiceConfiguration CreateReportServiceConfiguration()
    {
        var resolver = new Telerik.Reporting.Services.WebApi.ReportFileResolver(HttpContext.Current.Server.MapPath("~/Reports"))
            .AddFallbackResolver(new Telerik.Reporting.Services.WebApi.ReportTypeResolver());

        return new Telerik.Reporting.Services.ReportServiceConfiguration
        {
            HostAppId = "Application1",
            ReportResolver = resolver,
            Storage = new Telerik.Reporting.Cache.File.FileStorage(),
        };
    }
}
Example based on the article Dependency Injection in ASP.NET Web API 2
2. ReportsController implementation
public class ReportsController : Telerik.Reporting.Services.WebApi.ReportsControllerBase
{
    public ReportsController(Telerik.Reporting.Services.ReportServiceConfiguration configuration)
    {
        this.ReportServiceConfiguration = configuration;
    }
}
3. Invoke the setup in the Application_Start method
public class MvcApplication : System.Web.HttpApplication
{
    protected void Application_Start()
    {
        WebApiConfig.RegisterDependencies(System.Web.Http.GlobalConfiguration.Configuration);
        //...
    }
}

See Also