asp.net-core - 部署时如何自动从“../ReportApi”更改它?
问题描述
我已经使用 Syncfusion 报告查看器制作了 rdlc 报告和查看,它运行成功。但是,当我将它部署在服务器中时,找不到报告。我必须从这里手动更改路径(我附上的代码)
</script>
<ej-script-manager></ej-script-manager>
解决方案
在我们的 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 应用程序时如何包含文件。
推荐阅读
- oracle - 使用 oracle 数据库对 Spring Boot 应用程序进行 Dockerizing
- ios - 如何在条形顶部显示条形值?
- java - 要打印的数组的非相邻元素的最大总和
- java - 如何从 Java 中的超类访问子类?
- postgresql - Concatenate result of a SELECT into an EXECUTE
- date - 在赛普拉斯的日期输入上按 Enter
- c - 如果有的话,在 C 中如何“接近”其他变量存储的规则是什么?
- android - 将单个文本视图拆分为多个页面
- python - 使用 Pandas DataFrame 逐行查找过去 6 个月的事件
- hazelcast - 从应用程序定义地图加载器的正确方法 - hazelcast