I'm using Telerik Reporting R1 2019 for ASP.NET Core where the Reporting Services and the HTML5 viewer is at the same project.
Can you direct me to the correct documentation regarding how to set the connection string in this project ?
As I cannot seem to make it work. When it moves to "netcoreapp2.2" does it still need "App.config" to store the connection string ?
I keep getting the unable to connect to database.
7 Answers, 1 is accepted
I noticed that you opened a support ticket (#1385458) with same question. Please let me post my answer here as well:
"App configuration in ASP.NET Core uses the new SDK-style project and utilizes appsettings.json as a configuration file. We removed the need of the app.config file. The ConnectionStrings setting should be configured in JSON-based format like for example:
//appsettings.json
"ConnectionStrings"
: [
{
"name"
:
"Telerik.Reporting.Examples.CSharp.Properties.Settings.TelerikConnectionString"
,
"connectionString"
:
"Data Source=.\\SQLEXPRESS;Initial Catalog=AdventureWorks;Integrated Security=true"
,
"providerName"
:
"System.Data.SqlClient"
}
]
For more information about Telerik Reporting JSON-based configuration structure, please refer to Telerik Reporting Configuration Layout help article.
I need to mention that appsettings.json would be respected if there is an additional configuration included in Startup.cs. In our demos, we provide a new class named ConfigurationService which ensure reading the appsettings.json as config file and used in the ReportsController constructor:
public
class
ConfigurationService
{
public
IConfiguration Configuration {
get
;
private
set
; }
public
IHostingEnvironment Environment {
get
;
private
set
; }
public
ConfigurationService(IHostingEnvironment environment)
{
this
.Environment = environment;
var configFileName = System.IO.Path.Combine(environment.ContentRootPath,
"appsettings.json"
);
var config =
new
ConfigurationBuilder()
.AddJsonFile(configFileName,
true
)
.Build();
this
.Configuration = config;
}
}
You could refer to the new conceptual documentation article .NET Core Support that explains how to use reports in pure .NET Core application for Windows and Linux platforms.
Additionally, Telerik Reporting ships with a ready-made ASP.NET Core example that demonstrates how to show the sample reports in an ASP.NET Core application. The example also shows how to inject an appsettings.json configuration file to the controller and how to initialize a WebHostBuilder so it runs under Windows and Linux.
The example can be found in the \Examples\CSharp\Asp.NetCoreDemo sub-folder of the Telerik Reporting installation directory."
Regards,
Silviya
Progress Telerik

In that case, can you show me a sample of the appsettings.json for Postgres as a database?
I tried to set like below but the report keep tried to connect to SQL Server.
"ConnectionStrings": [
{
"name": "ConnectionName",
"connectionString": "Server=127.0.0.1;Database=kb;User Id=postgres;Password=postgres",
"providerName": "Npgsql"
}
]
Let me post my answer here as well:
"You are absolutely correct. At this moment, the Telerik Reporting assemblies are built against .NET Standard 2.0 framework. This version has missing support for DbProviderFactories. In general, without DbProviderFactories there's no built-in support for using ADO.NET components without taking a dependency on the data access provider library such System.Data.SqLite, System.Data.Npgsql or System.Data.MySql etc.
The good think is that it would be included in the new .NET Standard 2.1 and it would be supported with Telerik Reporting as well.
Still, we consider this as valid feedback, so I logged it as new feature request on our public Feedback portal on your behalf (Support for DbProviderFactories).
I'm afraid that there is no workaround at the moment."
Regards,
Silviya
Progress Telerik

In a production environment it is common to use appsettings.Production.json and appsettings.Development.json. How do I get the connection string when it is stored in an environment specific config file. We read the config with the following code.
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
var config = new ConfigurationBuilder().AddJsonFile($"appsettings.{env}.json").Build();
var uiConfig = config.GetSection("UiConfig").Get<UiConfig>();
Thanks.
Hi Tim,
To be able to use appsettings.[evn].json, make the following setting in ConfigurationHelper class:
public static IConfiguration ResolveConfiguration(IWebHostEnvironment environment)
{
string configFileName = null;
if (environment.IsDevelopment())
{
configFileName = "appsettings.Development.json";
}
else
{
configFileName = "appsettings.Production.json";
}
var reportingConfigFileName = System.IO.Path.Combine(environment.ContentRootPath, configFileName);
return new ConfigurationBuilder()
.AddJsonFile(reportingConfigFileName, true)
.Build();
}
The attached project demonstrates the approach.
Regards,
Neli
Progress Telerik

Any update about it?
I'm trying to use with Oracle.
Hello Henrique,
Have you tested this approach provided in my response? You may be also interested in the suggestion in the How to Retrieve the Oracle Connection Strings from Environment Variables KB article.
Please, let us know if you need further assistance.
Regards,
Neli
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Basically, you can set only the URL and the parameters of the Web Service DataSource. If you want to set the URL from the appsettings.json file, you may test to make your custom implementation of the IConfiguration:
public void ConfigureServices(IServiceCollection services)
{
...
// Configure dependencies for ReportsController.
services.TryAddSingleton<IReportServiceConfiguration>(sp =>
new ReportServiceConfiguration
{
ReportingEngineConfiguration = sp.GetService<IConfiguration>(),
...
});
}
You may also find helpful the How to customize WebServiceDataSource URL KB article.