Using Viewer Parameters
Our sample projects and report templates can help you learn the basics of working with our products.The viewer can be driven from your application through a properties object — for instance to switch which report is shown at run time.
Read the properties and load the chosen report.
How it works. The React component passes properties with each request, so the controller can vary the report it returns without new endpoints.
Read the properties and load the chosen report.
public IActionResult GetReport()
{
var reportName = "MasterDetail.mrt";
var httpContext = new Stimulsoft.System.Web.HttpContext(this.HttpContext);
var properties = httpContext.Request.Params["properties"]?.ToString();
if (properties != null)
{
var json = Encoding.UTF8.GetString(Convert.FromBase64String(properties));
var jsonObject = JsonConvert.DeserializeObject(json) as JToken;
reportName = jsonObject["reportName"]?.ToString() ?? reportName;
}
var report = StiReport.CreateNewReport();
report.Load(StiReactHelper.MapPath(this, $"Reports/{reportName}"));
return StiReactViewer.GetReportResult(this, report);
}Request.Params["properties"]— a base64-encoded JSON payload the React app sends to parameterize the viewer.- Decode and parse it to choose the report file, so the same viewer serves different content on demand.
How it works. The React component passes properties with each request, so the controller can vary the report it returns without new endpoints.