VS2010 ReportViewer keeps loading with Windows Azure Reporting Service

…衆ロ難τιáo~ 提交于 2019-12-25 03:00:21

问题


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)

回答1:


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>



回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/12580016/vs2010-reportviewer-keeps-loading-with-windows-azure-reporting-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!