Search code examples
c#htmlasp.net-mvc-5reportviewer

ReportViewerForMvc report content is blank


i had created a .rdlc with only background image.

when i render the report in mvc view page, the reportviewer have blank content. But if i download as pdf, excel or word, it have content.

in controller page

        ReportViewer rv = new ReportViewer();
        rv.Height = Unit.Parse("100%");
        rv.Width = Unit.Parse("100%");
        rv.LocalReport.DataSources.Clear();
        rv.ProcessingMode = ProcessingMode.Local;

        rv.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath)
            + @"Report\Test.rdlc";


        rv.LocalReport.Refresh();

        ViewBag.ReportViewer = rv;
        return View(RM);

in .cshtml page

    <div class="row">
        <div class="col-sm-offset-1 col-sm-10">
            <button>Generate</button>
            @if (ViewBag.ReportViewer != null)
            {
                @Html.ReportViewer(ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer, new { @style = "width:100%;height:600px" })
            }
        </div>
    </div>

in .aspx page

<%@ Page Language="C#" AutoEventWireup="True" Inherits="ReportViewerForMvc.ReportViewerWebForm" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.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">
    <title></title>
</head>
<body style="margin: 0px; padding: 0px;">
    <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
                <Scripts>
                    <asp:ScriptReference Assembly="ReportViewerForMvc" Name="ReportViewerForMvc.Scripts.PostMessage.js" />
                </Scripts>
            </asp:ScriptManager>
            <rsweb:ReportViewer ID="ReportViewer1" AsyncRendering="false" runat="server"
                 Width="100%" Height="600px"></rsweb:ReportViewer>
        </div>
    </form>
</body>
</html>

output

enter image description here


Solution

  • Here you can find a fix for this problem SO question.

    It seems that the styles and elements are built for use on Internet Explorer.