Hi Telerik Team,
I am designing a report using Telerik Report Designer and have connected multiple Web Service Data Sources that require 2-step authentication.
The reports are stored on the Telerik Report Server and are displayed in my ASP.NET MVC project using report server credentials and the report path (Category/ReportName). I have created the following function to connect to the report server:
using System.Web.Mvc;
using Telerik.Reporting;
using Telerik.ReportViewer.Mvc;
using System.Collections.Generic;
using System;
namespace Project.Extensions
{
public static class ReportExtension
{
public static IReportViewerBuilder GetReportViewerConfig(this HtmlHelper htmlHelper, string reportId, string reportSource, Dictionary<string, string> reportParams)
{
var uriReportSource = new UriReportSource
{
Uri = reportSource
};
foreach (var param in reportParams)
{
uriReportSource.Parameters.Add(param.Key, param.Value);
}
return htmlHelper.TelerikReporting().ReportViewer()
.Id(reportId)
.ReportServer(new ReportServer()
{
Url = ReadConfigData.REPORT_SERVER_URL,
Username = ReadConfigData.REPORT_SERVER_USERNAME,
Password = ReadConfigData.REPORT_SERVER_PASSWORD
})
.ReportSource(uriReportSource)
.ViewMode(ViewMode.Interactive)
.ScaleMode(ScaleMode.FitPageWidth)
.PersistSession(false)
.SendEmail(new SendEmail { Enabled = true })
.Parameters(new Parameters
{
Editors = new Editors
{
MultiSelect = EditorTypes.ComboBox,
SingleSelect = EditorTypes.ComboBox
}
})
.EnableAccessibility(false);
}
}
}
Scenario: My API domain is https://abcapi.com, which is used in every report under the "Configure Data Retrieval" window of the Web Service Data Source.
My Requirement: If the domain name changes, I have to manually update the domain in every report and each Web Service Data Source, which is time-consuming and inefficient.
Question:
Is there a way to set the domain name dynamically, so that I only need to update it in one place? Also, where is the configuration of each Web Service Data Source stored — is it in the database or somewhere else?
Regards,
Prabesh Shrestha
Instead of hardcoding the domain in each report, use this configuration to dynamically retrieve the domain during runtime. For instance, you could use a web.config or appsettings.json file to define and update the domain in one place.
block blast