0
votes

With VS2010 I have started a fresh Azure project with one MVC2 webrole that has only one Asp.Net webform.

Problem

I'm running into a problem that my ReportViewer keeps loading and I can't get it working properly with version 10.0? Version 9.0 is working like a charm, but I can't find the differences between these two.

Internet Explorer keeps blinking, but with Chrome's 'inspector' I can see that the following error occurs:

<h2> Report Viewer Configuration Error </h2><p>The Report Viewer Web Control HTTP Handler has not been registered in the application&#39;s web.config file. Add &lt;add verb=&quot;*&quot; path=&quot;Reserved.ReportViewerWebControl.axd&quot; type = &quot;Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot; /&gt; to the system.web/httpHandlers section of the web.config file, or add &lt;add name=&quot;ReportViewerWebControlHandler&quot; preCondition=&quot;integratedMode&quot; verb=&quot;*&quot; path=&quot;Reserved.ReportViewerWebControl.axd&quot; type=&quot;Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot; /&gt; to the system.webServer/handlers section for Internet Information Services 7 or later.</p>

What I did so far

I drag and drop (as adviced on multiple sites) just one ScriptManager and ReportViewer.
The project references are created automatically and the web.config's assemblies looks OK.

    <add assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
    <add assembly="Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />

The next step I do is add the handler to the web.config:

<system.web>
   <httpHandlers>
      <add path="Reserved.ReportViewerWebControl.axd" verb="*" 
      type="Microsoft.Reporting.WebForms.HttpHandler, 
      Microsoft.ReportViewer.WebForms, Version=10.0.0.0, 
      Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false" 
      />
   </httpHandlers>
</system.web>

<system.webServer>
  <validation validateIntegratedModeConfiguration="false" />
  <modules runAllManagedModulesForAllRequests="true" />

  <!-- added handler for reporting -->
  <handlers>
    <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </handlers>
</system.webServer>

After that I set the reporting properties within <script runat="server"></script> so that I can debug easily.

My webform

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Report.aspx.cs" Inherits="MvcWebRole1.Reports.Report" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            ReportViewer1.ProcessingMode = ProcessingMode.Remote;
            ReportViewer1.ServerReport.ReportServerUrl = new Uri("https://XXXX.reporting.windows.net/ReportServer");
            ReportViewer1.ServerReport.ReportPath = "/MyReport.rdl";
            ReportViewer1.ServerReport.ReportServerCredentials = new Credentials();
        }

        public class Credentials : IReportServerConnection
        {
            public IEnumerable<System.Net.Cookie> Cookies { get { return null; } }
            public Uri ReportServerUrl { get { return new Uri("https://XXXX.reporting.windows.net/ReportServer"); } }
            public int Timeout { get { return 60000; } }

            public bool GetFormsCredentials(out System.Net.Cookie authCookie, out string userName, out string password, out string authority)
            {
                authCookie = null;
                userName = "MyUserName";
                password = "MyPassword";
                authority = "XXXX.reporting.windows.net";
                return true;
            }
            public System.Security.Principal.WindowsIdentity ImpersonationUser { get { return null; } }
            public System.Net.ICredentials NetworkCredentials { get { return null; } }
        }

    </script>
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <rsweb:ReportViewer ID="ReportViewer1" runat="server">
        </rsweb:ReportViewer>
    </div>
    </form>
</body>
</html>

What's next?

Does anyone has any idea how I can resolve this issue!?

So, so far:

  1. Reporting Version 10.0
  2. Web.config looks OK for assemblies and handlers as well
  3. I tried visual studio debugger
  4. I tried IIS Express
  5. I tried an Windows Azure project (with emulator)
3

3 Answers

0
votes

Have you tried adding the httpHandler in system.web?

<system.web>
   <httpHandlers>
      <add path="Reserved.ReportViewerWebControl.axd" verb="*" 
      type="Microsoft.Reporting.WebForms.HttpHandler, 
      Microsoft.ReportViewer.WebForms, Version=10.0.0.0, 
      Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false" 
      />
   </httpHandlers>
</system.web>
0
votes

After having spent the day debugging a similar report viewer problem with a similar setup to yours but with MVC3 and 2012 I can tell you that the HttpHandler block that you can see is a red herring. The report viewer control outputs that block of HTML even if everything is working fine.

On the off chance that your problem is the same as mine, check the parameters that are passed into the report. If any of them are "" then the report viewer won't load. Change that parameter to " " or just don't pass it in. I'm afraid I have no good reason as to why this is the case.

0
votes

Well, it seems that the 'error message' is always there, waiting to be shown!! So don't let it fool you!

In the end I was very close to my solution... I only needed to add one simple line (which only took me a couple of hours):

if(!IsPostBack){
    // All my ReportViewer1 stuff goes here
}

This page I found very useful as well: Configuring ReportViewer for Asynchronous Rendering.