【问题标题】:WebForms ReportViewer control error. "Client found response content type of '', but expected 'text/xml'."WebForms ReportViewer 控件错误。 “客户端发现响应内容类型为 '',但预期为 'text/xml'。”
【发布时间】: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


【解决方案1】:

错误实际上是告诉我ReportServerUrl 是错误的。在我的情况下,而不是

http://domain/ReportServer/ReportViewer.aspx?

我应该实际使用

http://domain/ReportServer

此后错误消失,因为它能够连接到报告。但是,由于 .aspx 文件存在问题,因此没有显示任何内容。文件的 UI 内容没有加载到页面中,导致页面为空。

【讨论】:

    猜你喜欢
    • 2010-11-05
    • 1970-01-01
    • 1970-01-01
    • 2012-02-06
    • 2011-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多