【问题标题】:Using report viewer in asp.net to consume rdl file from server在 asp.net 中使用报表查看器从服务器使用 rdl 文件
【发布时间】:2023-03-09 07:17:01
【问题描述】:

我已经在服务器上部署了我的 ssrs 项目和报告。现在我必须在我的 asp.net 中使用它们 应用。我已经编写了在几个链接上找到的基本代码。但我想我不是 传递正确的服务器 uri 和 rdl 文件路径。你能告诉我一些关键点吗 要成功吗?

我们必须在这个字段中提供什么 reportViewer.ServerReport.ReportServerUrl=?

1) 是报表管理器的 URL 还是它的服务器路径。其实我有两件事。 一个是 url,另一个是带有报表服务器的 Serverip。我在报表服务器中使用服务器名称。但它也不起作用

 reportViewer.ServerReport.ReportServerUrl = new Uri("http://SomeIp/ReportServer");

如果我尝试导航 URI,它会显示浏览器中的目录和报告。 表示其正确且有效。我还有一个报告经理的 URL。我应该通过那个吗? 但这样也行不通。

2) 我可能做错的其他事情是报告文件路径。我是否必须从我的应用程序中提供文件路径或 它是托管或部署报告的服务器目录的路径。路径到底是什么

如果我浏览报告管理器网址,http://films.braintech-dev.com/Reports

在这里我可以看到带有名为“film.Reporting”的文件夹的 SSRS 主页,并且我可以在其中看到我的报告 “电影摘要报告”。

所以我使用下面作为我的文件路径

reportViewer.ServerReport.ReportPath = "/film.Reporting/FilmSummaryReport";

3) 或者我的 .rdl 扩展名可能是错误的。是必需的吗?但根据互联网扩展是不需要的。

顺便说一句,我在使用报表查看器时遇到了这个错误

Server Error in '/' Application.

The request failed with HTTP status 401: Unauthorized.

请查看完整代码

   var objList = this._service.GetAllRecords()

    ReportViewer reportViewer = new ReportViewer
    {
        ProcessingMode = ProcessingMode.Remote
    };

    IReportServerCredentials irsc = new ReportServerConnection("film12/srs", "ssrs123", "http://films.braintech-dev.com/Reports");

    reportViewer.ServerReport.ReportServerCredentials = irsc;

    reportViewer.ServerReport.ReportServerUrl = new Uri("http://SomeIp/ReportServer");

    reportViewer.ServerReport.ReportPath = @"/film.Reporting/FilmSummaryReport";

    reportViewer.Width = Unit.Percentage(100);

    reportViewer.LocalReport.DataSources.Add(new
        ReportDataSource("DataSet1", objList));

    reportViewer.LocalReport.Refresh();

    this.ViewBag.ReportViewer = reportViewer;
    return this.View();

【问题讨论】:

  • 你能发布你的整个代码块吗?您使用"http://SomeIp/ReportServer" 是正确的
  • 我已经添加了我的代码。你能看看吗?
  • 你为什么要从ServerReport切换到LocalReport?
  • 正确的代码应该是什么?
  • 我认为它给了你The request failed with HTTP status 401: Unauthorized.,因为你已经为ServerReport 设置了连接,但是你在LocalReport 上设置了Refresh()。尝试将所有逻辑更改为ServerReport。

标签: c# asp.net reporting-services reporting ssrs-2008-r2


【解决方案1】:

如果运行该网站的网站已部署且未在 Visual Studio 中运行,则验证正在运行应用程序池的用户是否有权访问报告。

【讨论】:

  • 实际上原始密码是 "film12\srs" 但 c sharp 不允许我在字符串中使用反斜杠。所以我使用了“film12/srs”。也可能是它仍然未经授权的原因。但应该有一个相关的错误,如 .密码不匹配?
  • 起初我没有使用网络凭据。但是现在我已经实现了 IReportServerConnection 并通过了网络连接。我不确定我错在哪里。
猜你喜欢
  • 2010-10-08
  • 2017-01-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-04
相关资源
最近更新 更多