title: Extremely slow rendering of Reportviewer in ASP.Net MVC
body: <p>I have been looking for a solution for doing reporting in ASP.Net MVC, and I did come across a solution by Rai Kaimal  <a href="http://weblogs.asp.net/rajbk/archive/2009/11/25/rendering-an-rdlc-directly-to-the-response-stream-in-asp-net-mvc.aspx" rel="nofollow">Rendering an RDLC directly to the Response stream in ASP.NET MVC</a>. Everything works just fine, but the localReport.Render() function takes extremely long to render the page (40 seconds for 2 very simple pages - the same reports executes in 2 seconds from a winforms solution). Any help would be appreciated. If there's no way to speeding up the report, I'm interested in knowing how other developers handle the reporting in a ASP.Net MVC solution.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    public ActionResult CustomerReport()
      {
          var localReport = new LocalReport
                                {
                                    ReportPath = Server.MapPath("~/Reports/CustomerReport.rdlc")
                                };
          var reportDataSource = new ReportDataSource("Customers", _repository.GetAll( ));
  
          localReport.DataSources.Add(reportDataSource);
  
          const string reportType = "PDF";
  
          string mimeType;
          string encoding;
          string fileNameExtension;
  
          //The DeviceInfo settings should be changed based on the reportType
  
          //http://msdn2.microsoft.com/en-us/library/ms155397.aspx
  
          const string deviceInfo = "&lt;DeviceInfo&gt;" +
                                    "  &lt;OutputFormat&gt;PDF&lt;/OutputFormat&gt;" +
                                    "  &lt;PageWidth&gt;8.5in&lt;/PageWidth&gt;" +
                                    "  &lt;PageHeight&gt;11in&lt;/PageHeight&gt;" +
                                    "  &lt;MarginTop&gt;0.5in&lt;/MarginTop&gt;" +
                                    "  &lt;MarginLeft&gt;1in&lt;/MarginLeft&gt;" +
                                    "  &lt;MarginRight&gt;1in&lt;/MarginRight&gt;" +
                                    "  &lt;MarginBottom&gt;0.5in&lt;/MarginBottom&gt;" +
                                    "&lt;/DeviceInfo&gt;";
  
          Warning[] warnings;
          string[] streams;
  
          //Render the report
          byte[] renderedBytes = localReport.Render(
              reportType,
              deviceInfo,
              out mimeType,
              out encoding,
              out fileNameExtension,
              out streams,
              out warnings);
  
          return File(renderedBytes, mimeType);
      }
  </code></pre>