title: Why is my Crystal Report and Viewer invisible on a Web Form in an MVC application?
body: <p>I'm copying code from an example MVC 3 application into my new MVC 4 application. The code sets report parameters into Session, i.e. the report name and the report data, and then calls an .aspx page with only a CrystalReportViewer on it to show the report:</p>
  
  <pre><code>public class ReportController : Controller
  {
      public ActionResult Terminal()
      {
          Session["ReportName"] = "Terminal.rpt";
          using (var sqn = new SqlConnection("Data Source=(Local);Initial Catalog=ParkPay;Integrated Security=SSPI;MultipleActiveResultSets=True;"))
          {
              var adap = new SqlDataAdapter("select * from parkpay.Terminal", sqn);
              var dt = new DataTable();
              adap.Fill(dt);
              Session["ReportData"] = dt;
          }
          return RedirectToAction("ShowReport", "AspxReportViewer");
      }
  }
  
  public class AspxReportViewerController : Controller
  {
      public void ShowReport()
      {
          Response.Redirect("~/AspxForms/ReportViewer.aspx");
      }
  }
  </code></pre>
  
  <p>The web form:</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ReportViewer.aspx.cs" Inherits="ParkPay.Reports.Crystal.AspxForms.ReportViewer" %&gt;
  
  &lt;%@ Register Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.Web" TagPrefix="CR" %&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form" runat="server"&gt;        
          &lt;CR:CrystalReportViewer ID="CrystalReportViewer" runat="server" AutoDataBind="true" /&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The two projects - mine and the example - are nearly identical, yet when I call a report action such as Terminal on my project, all I get is a blank page. It has a Crystal viewer on it, which is a <code>div</code> full of JavaScript way beyond my level.</p>
  
  <p>The main work is done in the code behind for <code>ReportViewer.aspx</code>:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      var reportDoc = new ReportDocument();
      var reportName = Session["ReportName"].ToString();
      var dataSource = Session["ReportData"] as DataTable;
      var reportPath = Path.Combine(Server.MapPath("~/Reports"), reportName);
      reportDoc.Load(reportPath);
      reportDoc.SetDataSource(dataSource);
      CrystalReportViewer.ReportSource = reportDoc;
  }
  </code></pre>
  
  <p>This is identical in both the example and my project. If I copy one of my reports to the example project, it works perfectly. Both web.config files look identical. There are no 'special' files in the example report not in mine. The only obvious difference is my project is the startup project in a small solution, where the example project is standalone. In a solution, but alone there.</p>
  
  <p>What could either be wrong with mine, or what could be the difference? I'm thinking of simply moving all my reports to the example and calling out to it from my project.</p>
  
  <p><strong>NOTE:</strong> The JavaScript console shows these errors:</p>
  
  <pre><code>Failed to load resource: the server responded with a status of 404 (Not Found):  http://localhost:17441/aspnet_client/system_web/4_0_30319/crystalreportviewers13/js/crviewer/crv.js
  </code></pre>
  
  <p>and </p>
  
  <pre><code>Failed to load resource: the server responded with a status of 404 (Not Found):  http://localhost:17441/aspnet_client/system_web/4_0_30319/crystalreportviewers13/js/crviewer/images/style.css
  </code></pre>
  
  <p>and the two</p>
  
  <pre><code>Uncaught ReferenceError: bobj is not defined:   ReportViewer.aspx:56 ReportViewer.aspx:64
  </code></pre>