首页 > 解决方案 > 部署时如何自动从“../ReportApi”更改它?

问题描述

我已经使用 Syncfusion 报告查看器制作了 rdlc 报告和查看,它运行成功。但是,当我将它部署在服务器中时,找不到报告。我必须从这里手动更改路径(我附上的代码)

</script>
<ej-script-manager></ej-script-manager>

标签: asp.net-corereporting-servicesrdlcsyncfusion

解决方案


在我们的 ASP.NET Core 应用程序中,我们从 wwwroot 文件夹获取报告路径。因此,我们使用 WebRootPath 来获取 wwwroot 文件夹路径,如下面的代码示例所示。在生产方面,我们需要包含报告路径。

public void OnInitReportOptions(ReportViewerOptions reportOption)
        {
            string basePath = _hostingEnvironment.WebRootPath;
            FileStream inputStream = new FileStream(basePath + @"\ReportData\InvoiceTemplate.rdl", FileMode.Open, FileAccess.Read);
            reportOption.ReportModel.Stream = inputStream;
        }

请参阅帮助文档,了解在发布 ASP.NET Core 应用程序时如何包含文件。


推荐阅读