【发布时间】:2017-10-16 06:25:16
【问题描述】:
我正在尝试通过在单击按钮时将其重定向到包含 ReportViewer 控件的 .aspx 文件来测试从 .cshtml 文件在浏览器中托管报告的服务器加载 SSRS 报告。
<rsweb:ReportViewer ID="ReportViewer1" runat="server"></rsweb:ReportViewer>
在.aspx文件的后端,我添加了以下内容:
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
IReportServerCredentials irsc = new ReportServerCredentials("username", "password", "domain");
ReportViewer1.ServerReport.ReportServerCredentials = irsc;
ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://domain/ReportServer/ReportViewer.aspx");
ReportViewer1.ServerReport.ReportPath = "/Report/path";
ReportViewer1.ServerReport.SetParameters(new ReportParameter[] {
new ReportParameter("param1", "sample1"),
new ReportParameter("param2", "sample2")
});
ReportViewer1.ServerReport.Refresh();
“ReportServerCredentials”类是实现 IReportServerCredentials 的类。
我尝试使用浏览器使用用户名和密码连接到指定域并查看指定'ReportPath'中的报告,并验证我可以成功访问和查看报告。
但是,当程序运行并点击这个方法时:
ReportViewer1.ServerReport.SetParameter
出现此错误:
Client found response content type of '', but expected 'text/xml'.
The request failed with an empty response.
是什么导致了这个问题?
【问题讨论】:
-
尝试通过在扩展后添加问号 (
?) 来更改 URL,如下所示:ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://domain/ReportServer/ReportViewer.aspx?");。 -
我尝试在 ReportPath 中添加
?并删除/,但没有帮助。 -
我不会告诉你改变
ReportPath- 你试过建议ReportServerUrl了吗?如果存在这样的设置,也可以尝试将ContentType设置为text/xml,因为报告数据需要 XML 格式,但收到的是 null 或空。 -
我的错。我不应该在同一个句子中组合这些词。是的,我已经在
ReportServerUrl中尝试过?。我还尝试在ReportPath中添加和删除/,以防万一,但结果仍然相同。默认情况下它已经期待 text/xml,但我也尝试添加内容类型,结果仍然相同。 -
我测试了将
ReportPath更改为指向不存在的报告,它给出了与上述相同的错误。我相信它由于某种原因找不到我的报告?
标签: c# reporting-services reportviewer