rpmansion
rpmansion

Reputation: 2014

SSRS rendered report in MVC causing a 404 error

I'm getting an issue, see the below, when rendering a pdf report from our SSRS. I have tried to look into different sources and nothing works so far.

Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.MissingEndpointException: 'The attempt to connect to the report server failed. Check your connection information and that the report server is a compatible version.'

I have these line of codes which should work:

var parameters = new List<ReportParameter>
{ 
    new ReportParameter("paramter_1", "paramter_1_value"), 
};
var reportServerUrl = ConfigurationManager.AppSettings["ReportServerUrl"];
reportViewer.ServerReport.ReportServerUrl = new Uri(reportServerUrl);
reportViewer.ServerReport.ReportPath = '/ReportFolder/ReportName';
reportViewer.ServerReport.ReportServerCredentials = new CustomCredentials();
reportViewer.ServerReport.SetParameters(parameters);
reportViewer.ServerReport.Refresh();

var mimeType = "";
var encoding = "";
var filenameExtension = "pdf";
string[] streamids = null;
Warning[] warnings = null;
var outputFileName = "File_Name.pdf";
var bytes = reportViewer.ServerReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);
var pdfReport = File(bytes, "application/pdf", outputFileName);

Am I doing anything wrong here?

Upvotes: 0

Views: 1227

Answers (2)

rpmansion
rpmansion

Reputation: 2014

For anyone who might experience this, It's a silly mistake. I've been using the http://server/reports which is used to open a report on the web.

You might want to check the Report Server Configuration Manager and make sure you use the URL that is pointing to the configured virtual path. So say, the virtual path is reportserver, you have to use this as your ReportServerUrl in order for you to render a report.

reportViewer.ServerReport.ReportServerUrl = new Uri("http://server/reportserver");

Upvotes: 1

RustMan
RustMan

Reputation: 66

A few things you can try:

  1. Try to ping the server from where you are trying to access the report and see if you can reach it. If you cannot reach it with a ping. If you cannot ping it, it might be that a firewall is the problem. Pinging might be disabled on the server so make sure this is not the case. The fact is that if you cannot reach the Report Server from your code, you will not be able to run the report.
  2. Make sure the path you are using for the ReportServerUrl is the same one configured in the Report Server Configuration Manager on the machine where the report server is installed.
  3. Make sure that the certificates are installed. Check this link: https://blog.jpries.com/2017/02/11/troubleshooting-error-404-error-400-or-invalid-request-or-bad-connection-in-a-new-ssrs-installation/

Upvotes: 1

Related Questions