title: MVC 5/ReportViewer/ASP.NET client-side AJAX errors
body: <p>I'm at wits end. I'm trying to load up a ReportViewer with both valid aspx code and ReportViewerForMVC code wind up here. First, the error spread:</p>
  
  <blockquote>
    <p>Uncaught SyntaxError: Unexpected token &lt; WebResource.axd:1 </p>
    
    <p>Uncaught SyntaxError: Unexpected token &lt; GetSysWideQuizReport:67 </p>
    
    <p>Uncaught ReferenceError: ReportViewerForMvc is not defined(anonymous
    function) @ GetSysWideQuizReport:67  Uncaught SyntaxError: Unexpected
    token &lt;  ScriptResource.axd:1 </p>
    
    <p>Uncaught SyntaxError: Unexpected token &lt; ReportViewerWebForm.aspx:40 </p>
    
    <p>Uncaught Error: ASP.NET Ajax client-side framework failed to
    load.(anonymous function) @ ReportViewerWebForm.aspx:40
    ScriptResource.axd:1 </p>
    
    <p>Uncaught SyntaxError: Unexpected token &lt; ScriptResource.axd:1 </p>
    
    <p>Uncaught SyntaxError: Unexpected token &lt;
    Reserved.ReportViewerWebControl.axd:1 </p>
    
    <p>Uncaught SyntaxError: Unexpected token &lt; ScriptResource.axd:1 </p>
    
    <p>Uncaught SyntaxError: Unexpected token &lt; ReportViewerWebForm.aspx:51 </p>
    
    <p>Uncaught ReferenceError: Sys is not defined(anonymous function) @
    ReportViewerWebForm.aspx:51  ReportViewerWebForm.aspx:114 </p>
    
    <p>Uncaught ReferenceError: Sys is not defined  ReportViewerWebForm.aspx:114</p>
  </blockquote>
  
  <p>The View:</p>
  
  <pre><code> @using ReportViewerForMvc;
  @using Microsoft.Reporting.WebForms;
  @using App.Models;
  
  &lt;style&gt;
      iframe{
          width:900px;
      }
  &lt;/style&gt;
  @{
      ViewBag.Title = "LocalReportExample";
  }
  
  
      &lt;h2&gt;Local report example&lt;/h2&gt;
  
  @Html.ReportViewer(ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer)
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>  public ActionResult GetSysWideQuizReport([Bind(Include = "Topic, Date1, Date2")] QuizReporting quizParams)
              {
                  ReportViewer reportViewer = new ReportViewer();
                  reportViewer.ProcessingMode = ProcessingMode.Local;
  
                  reportViewer.SizeToReportContent = true;
                  reportViewer.Width = Unit.Percentage(100);
                  reportViewer.Height = Unit.Percentage(100);
                  reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"/ReportViews/System Quiz Report.rdlc";
                  reportViewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", QuizData(quizParams)));
    ViewBag.ReportViewer = reportViewer;
  
              return View();
  
   }
  
          private DataTable QuizData(QuizReporting quizParams)
          {
  
              DataSet ds = new DataSet("DataSet1");
  
                  using(SqlConnection connection = new SqlConnection())
                  { 
  
                  connection.ConnectionString = GetConnectionString();
  
                  SqlCommand cmd = new SqlCommand("SystemQuizReport", connection);
  
                  cmd.Parameters.AddWithValue("@TopicID", quizParams.Topic.TopicID);
                  cmd.Parameters.AddWithValue("@Date1", "2015/04/13");
                  cmd.Parameters.AddWithValue("@Date2", "2015/04/16");
                  cmd.CommandType = CommandType.StoredProcedure;
  
                  SqlDataAdapter da = new SqlDataAdapter();
                  da.SelectCommand = cmd;
                  da.Fill(ds);
                  return ds.Tables[0];
                  }
  
          }
  
          static private string GetConnectionString()
          {
              return "Data Source=(localdb)\\v11.0; Initial Catalog=LocalDb-20140822124213; Integrated Security=True;";
          }
  </code></pre>
  
  <p>An excerpt of web.config:</p>
  
  <pre><code>&lt;system.web&gt;
      &lt;httpHandlers&gt;
        &lt;add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" validate="false" /&gt;
      &lt;/httpHandlers&gt;
      &lt;authentication mode="None" /&gt;
      &lt;compilation debug="true" targetFramework="4.5"&gt;
        &lt;buildProviders&gt;
          &lt;add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /&gt;
        &lt;/buildProviders&gt;
      &lt;/compilation&gt;
      &lt;httpRuntime targetFramework="4.5" /&gt;
      &lt;!--&lt;hostingEnvironment shadowCopyBinAssemblies="false" /&gt; --&gt;
    &lt;/system.web&gt;
    &lt;system.webServer&gt;
      &lt;modules&gt;
        &lt;remove name="FormsAuthentication" /&gt;
      &lt;/modules&gt;
      &lt;validation validateIntegratedModeConfiguration="false" /&gt;
      &lt;handlers&gt;
        &lt;add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /&gt;
      &lt;/handlers&gt;
    &lt;/system.webServer&gt;
  </code></pre>
  
  <p>I've done the following to fix it:</p>
  
  <ul>
  <li>Made sure all Nuget packages/frameworks are up to date</li>
  <li>Examined the console output in Chrome. It looks like the AXD files are trying to render the base home page of my application, and I don't know why.</li>
  <li>Disabled all authorization requirements in FilterConfig and this has not worked.</li>
  </ul>
  
  <p>I'm pulling my hair out so much with this so I hope you can help me out!</p>