'Reportviewer RDLC issues in ASP NET MVC
I made use of Reportviewer on the ASP NET MVC Application and it works fine on the Localhost. But when I upload to production, it does not render the report. Rather it creates like a frame showing replica of the site.
The controller end code is below:
public ActionResult ReportOrderDetails()
{
ReportViewer reportViewer = new ReportViewer();
reportViewer.ProcessingMode = ProcessingMode.Local;
reportViewer.SizeToReportContent = true;
reportViewer.Width = Unit.Percentage(500);
reportViewer.Height = Unit.Percentage(500);
var connectionString = ConfigurationManager.ConnectionStrings["POSContext"].ConnectionString;
SqlConnection conx = new SqlConnection(connectionString);
string command = "SELECT Item_Name, salesPrice, SUM(qty) AS Qty, SUM(Qty * salesPrice) AS Amount FROM OrderDetails GROUP BY Item_Name, salesPrice ORDER BY Qty DESC";
SqlDataAdapter adp = new SqlDataAdapter(command, conx);
adp.Fill(ds, ds.Dt_OrderDetails.TableName);
reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"RDLCReports\Rpt_OrderDetails.rdlc";
reportViewer.LocalReport.DataSources.Add(new ReportDataSource("DtSet_OrderDetails", ds.Tables[0]));
ViewBag.ReportViewer = reportViewer;
return View();
}
The View Code is Below:
@using ReportViewerForMvc;
@{
ViewBag.Title = "ReportEmployee";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="w3-container" style="padding-left:10px">
<div class="col-sm-2"></div>
<div class="col-sm-8 w3-card-4" style="padding-left:40px; padding-right:20px">
<h2 class="w3-center"><strong> Aggregate Sales Report </strong></h2>
<div class="w3-row">
@using (Html.BeginForm("ReportOderDetails", "StockManagement", new { area =
"StockManagement" }, FormMethod.Post, new { id = "form" }))
{
@Html.ReportViewer(ViewBag.ReportViewer as
Microsoft.Reporting.WebForms.ReportViewer)
}
</div>
</div>
Attached is the screenshot on production server. enter image description here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
