带有.Net Core 3.1 MVC应用程序的SSRS报告

时间:2020-08-24 13:00:50

标签: ssrs-2012 asp.net-core-3.1

我正在尝试在.Net Core 3.1 MVC应用程序中显示SSRS报告。

我试图实施

中提到的方法

https://alanjuden.com/2016/11/10/mvc-net-core-report-viewer/?unapproved=58532&moderation-hash=321d5350c96d2fcf83baa4c939bbdf53#comment-58532

public class ReportsController : AlanJuden.MvcReportViewer.ReportController
{

    protected override ICredentials NetworkCredentials
    {
        get
        {
            //Custom Domain authentication (be sure to pull the info from a config file)
            return new System.Net.NetworkCredential("username", "password");

            //Default domain credentials (windows authentication)
            //return System.Net.CredentialCache.DefaultNetworkCredentials;
        }
    }

    protected override string ReportServerUrl
    {
        get
        {
            //You don't want to put the full API path here, just the path to the report server's ReportServer directory that it creates (you should be able to access this path from your browser: 
            return "https://YourReportServerUrl.com/ReportServer/ReportExecution2005.asmx";
        }
    }
    public IActionResult ProcessReport()
    {
        var model = this.GetReportViewerModel(Request);
        model.ReportPath = "reportPath";
        return RedirectToAction("ReportViewer", model);
    }}

,但不适用于最新框架。 我在运行项目时遇到以下错误-Error screenshot

感谢您的帮助。 谢谢!

2 个答案:

答案 0 :(得分:1)

同样的事情发生在我身上,就我而言,我需要安装一个告诉您安装的软件包

Install-Package System.ServiceModel.Http -Version 4.1.0

或在nuget中查找软件包System.ServiceModel.Http

答案 1 :(得分:0)

我使用最新的.NET Core尝试了不同的解决方法,包括您从Alan Juden提到的方法。但是,对我而言,最简单的方法是使用Microsoft的Report Viewer控件创建一个普通的.NET WebForms站点。它仍然是很多代码,但这很可靠,因为Report Viewer控件已经存在很多年了。

在我的情况下,它显示的是来自Angular UI的SSRS报告,但同样适用于MVC或任何其他Web UI,因为您实际上将重定向/导航到另一个URL(WebForms aspx页面)。

更多详细信息here