Question

I have looked just about everywhere for a solution to this issue and have not found one that has worked for me yet. I have a reporting server (2008 R2) set up on our hosting server. I have created a report from scratch using the report builder, tested it out while logging into the report server with its URL and it successfully generates reports.

When I try to view the report from our MVC application, only the reports toolbar renders (showing export, print, pages, and the view report button). It shows that it is "Loading", and after it completes it's just a blank report, but it shows the correct parameters on the toolbar, and if I change the name of the parameters in the code it returns an error stating the parameter doesn't exist; so I know the address user/pw information is correct.

Code and markup for the page

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="Comp.Proj.Core.Model"%>
<%@ Import Namespace="Comp.Proj.Core.Service" %>
<%@ Import Namespace="Microsoft.Reporting.WebForms" %>
<%@ Import Namespace="System.Security.Principal" %>
<%@ Import Namespace="System.Net" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

  <h2><a href="/Reporting">Back to Reports</a> / <%=ViewData["Report"]%></h2>
    <form action="/Reporting/DateViewer" method="get">
      Start Date:
      <input type="text" name="start" class="datepicker" value="<%=ViewData[" Start "] %>" /> End Date:
      <input type="text" name="end" class="datepicker" value="<%=ViewData[" End "] %>" />
      <input type="hidden" name="id" value="<%=ViewData[" Report "] %>" />
      <input type="submit" class="button" value="Run" />
    </form>

    <script runat="server" language="C#">
      protected void Page_Load(object sender, EventArgs e) {
        try {
          if (!IsPostBack) {
            if (ViewData["Start"] != null) {
              var param = new List < ReportParameter > ();


              var start = new ReportParameter("start", ViewData["Start"].ToString());
              var end = new ReportParameter("end", ViewData["End"].ToString());
              var region = new ReportParameter("region", "2");
              param.Add(start);
              param.Add(end);
              param.Add(region);
              ReportViewer1.Width = 1100;
              ReportViewer1.Height = 900;
              ReportViewer1.ShowCredentialPrompts = false;
              ReportViewer1.ShowDocumentMapButton = false;
              ReportViewer1.ShowExportControls = true;
              ReportViewer1.ShowFindControls = false;
              ReportViewer1.ShowPrintButton = true;
              ReportViewer1.ShowPromptAreaButton = false;
              ReportViewer1.ShowRefreshButton = false;
              ReportViewer1.ShowToolBar = true;
              ReportViewer1.ShowZoomControl = false;
              ReportViewer1.SizeToReportContent = true;
              ReportViewer1.ProcessingMode = ProcessingMode.Remote;
              IReportServerCredentials irsc =
                new CustomReportCredentials(ConfigurationManager.AppSettings["ReportServerUser"],
                                            ConfigurationManager.AppSettings["ReportServerPassword"], "SERVERNAME");
              ReportViewer1.ServerReport.ReportServerCredentials = irsc;
              ReportViewer1.ServerReport.ReportServerUrl =
                new Uri(string.Format("http://{0}/ReportServer",
                                      ConfigurationManager.AppSettings["ReportServerUrl"]));
              ReportViewer1.ServerReport.ReportPath = string.Format("/{0}", ViewData["Report"]);
              ReportViewer1.ServerReport.SetParameters(param);
              ReportViewer1.ShowReportBody = true;
              ReportViewer1.ServerReport.Refresh();
            }
          }
        } catch (Exception ex) {
          Response.Write(ex.Message);
        }
      }
    </script>

    <form id="form1" runat="server">
      <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
      <div>
        <rsweb:ReportViewer ID="ReportViewer1" runat="server" />
      </div>
    </form>

</asp:Content>

Web config

<assemblies>
    <add assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>

<buildProviders>
    <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</buildProviders>

<system.webServer>
    <handlers>
        <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </handlers>
</system.webServer>
Était-ce utile?

La solution

I finally got it to work. For those having the same issues as me, this is what I did to get it to work.

In the page directive, set EnableEventValidation="false" and for the report control set AsyncRendering="false".

Autres conseils

I never add to these solutions but I felt it was time I "give back" instead of just 'taking".

When my page had the following on the page load, the report viewer would show the parameters, but not the actual report. Please note I had AysncRendering=false. So this code did not work (VB).

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim UserName = HttpContext.Current.User.Identity.Name
    Dim paramList As New Generic.List(Of ReportParameter)
    paramList.Add(New ReportParameter("UserID", UserName, False))
    ReportViewer1.ServerReport.SetParameters(paramList)
End Sub

But when I added the following lines, with no other changes, the whole report loaded.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Dim UserName = HttpContext.Current.User.Identity.Name
    If IsPostBack = False Then
        ReportViewer1.Width = 900
        ReportViewer1.Height = 900

        Dim paramList As New Generic.List(Of ReportParameter)
        paramList.Add(New ReportParameter("UserID", UserName, False))
        ReportViewer1.ServerReport.SetParameters(paramList)
        ReportViewer1.ShowReportBody = True
        ReportViewer1.ServerReport.Refresh()
    End If

Note that I did not make any page declaration changes like previous post here mention.

What I did was to ensure all the web.config the the page use the reference ReportViewer 10. Strangely, the screen still showed blank page. Click Refresh, and it showed up. It probably due to the session.

the code below worked for me

I'm using reporting services 14 and setting the ReportViewer1.ServerReport.ReportServerUrl and ReportViewer1.ServerReport.ReportPath in the code behind.

Report1.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Report1.aspx.cs" Inherits="CIEM.Web.Reports.Report1" %>
<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> 
<title></title>
    <style>
    html,body,form,#div1 {
        height: 100%; 
    }
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="div1" >
        <asp:ScriptManager runat="server"></asp:ScriptManager>
    <rsweb:ReportViewer ID="ReportViewer1" runat="server" ProcessingMode="Remote" Height="100%" Width="100%">
    </rsweb:ReportViewer>
</div>
</form>
</body>

https://docs.microsoft.com/en-us/sql/reporting-services/application-integration/integrating-reporting-services-using-reportviewer-controls-get-started?view=sql-server-2017#set-the-height-of-all-the-ancestors-to-100

https://msdn.microsoft.com/en-us/library/ms252090.aspx

1.Explicitly set the height on the on the ReportViewer control to an actual value rather than a percentage.
2.Add the following style setting to the tag: html,body,form {height:100%}. By forcing the HTML, body, and form tags to maximum height, the frame used in the ReportViewer control will also grow to maximum height, making it visible on the page.
3.Remove the xhtml doctype from the page. (Important)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top