¿Cómo puedo usar los informes RDLC con el Control ReportViewer en ASP.Net MVC?

Soy bastante nuevo en ASP.Net MVC. Tengo el requisito de mostrar un informe basado en RDLC en MVC.

Básicamente, mi requisito y lo que he hecho es:

Tengo un ReportController que hereda APIController, que tiene un método que devuelve un DataSet. Este conjunto de datos se está enviando al archivo RDLC.

Para esto, hice lo siguiente, pero no pude hacer que el informe funcionara.

He creado una clase de modelo llamada ReportParameter de la siguiente manera:

public class ReportParameter 
{
    public DateTime DateFrom { get; set; }
    public DateTime DateTo { get; set; }
}

Tengo el siguiente controlador ReportViewController:

public class ReportViewController : Controller
{
    static readonly ReportController ctrl = new ReportController();

    public ActionResult GenerateReport()
    {
        return View();
    }

    [HttpPost]
    public ActionResult GenerateReport(ReportParameterSalesOrder param)
    {
        if (ModelState.IsValid)
        {
            Helpers.DataLayer dl = new Helpers.DataLayer();
            if (param.DateFrom != null)
            {
                DateTime DateFrom = Convert.ToDateTime(param.DateFrom);
                DateTime DateTo = Convert.ToDateTime(param.DateTo);

                string fdate = DateFrom.ToString("yyyy/MM/dd");
                string tdate = DateTo.ToString("yyyy/MM/dd");

                Session["ReportSales"] = ctrl.ReportSales(param);
            }

            return Redirect(Url.Action("ViewReport", "ReportView"));
        }
        return View();
    }
    public ActionResult ViewReport()
    {
         return View();
    }

}

Tengo un API Controller ReportController cuyo objeto se ha creado en el ReportViewerController anterior para generar un DataSet y llenar el informe RDLC. El controlador API es:

public class ReportController : ApiController
{

    static readonly IReportRepository repository = new ReportRepository();

    [ActionName("ReportSales")]
    public DataSet ReportSales(ReportParameterSalesOrder paramSO)
    {
        DataSet item = repository.ReportSales(paramSO);
        if (item == null)
        {
            throw new HttpResponseException(HttpStatusCode.NotFound);
        }
        return item;
    }
}

Tengo dos vistas GenerateReport.aspx y ViewReport.aspx. El GenerateReport.aspx se da a continuación:

<table style="width: 40%;">
              <tr>
                  <td class="style1">
                      <h3>
                          <asp:Label ID="Label1" runat="server" Text="From Date"></asp:Label></h3>
                  </td>
                  <td>
                      <%[email protected](a=> a.DateFrom, new{id="startDate",style="width:250px;"}) %>
                      <%[email protected](a => a.DateFrom)%>
                  </td>
              </tr>
              <tr>
                  <td class="style1">
                      <h3>
                          <asp:Label ID="Label2" runat="server" Text="To Date"></asp:Label></h3>
                  </td>
                  <td>
                      <%[email protected](a => a.DateTo, new { id = "ToDate", style = "width: 250px;" })%>
                      <%[email protected](a => a.DateTo)%>
                  </td>
              </tr>
              <tr>
                  <td class="style1">
                      &nbsp;
                  </td>
                  <td>
                      &nbsp;
                  </td>
              </tr>
              <tr>
                  <td class="style1">
                      &nbsp;
                  </td>
                  <td>
                      <input id="btnsearch" class="button" type="submit" value="Show" />
                  </td>
              </tr>
          </table>

El ViewReport.aspx se da a continuación:

 <center style="width: 974px">
      <iframe id="myReport" width="100%" height="450px" src="ReportViewer.aspx">

        </iframe></center>

He agregado un Dataset.xsd, un archivo rdlc y una página aspx para agregar el archivo rdlc.

Pero no puedo hacer que funcione. ¿Cómo visualizo el informe o cómo relleno el conjunto de datos que recibo del Controlador en el informe?

Respuestas a la pregunta(1)

Su respuesta a la pregunta