2017-10-16 39 views
0

我试图从一个.cshtml文件通过重定向到一个包含ReportViewer控件的.aspx文件的浏览器中的报告的服务器加载SSRS报告。WebForms ReportViewer控制错误。 “客户发现响应内容类型为'',但预计'text/xml'。”

<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' 类是一类imeplementing IReportServerCredentials。

我尝试使用浏览器使用用户名和密码连接到指定的域,并在指定的'ReportPath'中查看报告,并验证我可以成功访问和查看报告。

然而,当程序运行和点击这个方法:

ReportViewer1.ServerReport.SetParameter 

这个错误发生:

Client found response content type of '', but expected 'text/xml'. 
The request failed with an empty response. 

是什么原因造成这个问题?

+0

尝试通过在扩展后添加问号('?')来更改URL,如下所示:'ReportViewer1.ServerReport.ReportServerUrl = new Uri(“http://domain/ReportServer/ReportViewer.aspx?”);'。 –

+0

我试着在ReportPath中添加'?'并删除'/',这没有帮助。 – Khaimeng

+0

我不告诉你改变'ReportPath' - 你是否已经建议'ReportServerUrl'?如果存在这样的设置,也可以尝试将'ContentType'设置为'text/xml',因为报表数据需要XML格式,但接受空或空。 –

回答

0

该错误实际上告诉我,ReportServerUrl是错误的。在我的情况下,代替

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

我应该实际使用

http://domain/ReportServer 

错误后消失了,因为它能够连接到报表。但是,由于.aspx文件存在问题,因此无法显示。该文件的UI内容未加载到页面中,导致页面为空。

相关问题