ReportViewer未显示在页面上

本文关键字:显示 ReportViewer | 更新日期: 2023-09-27 18:16:59

我已经在这几个小时了,还没有找到一个解决方案,为我工作。我尽量解释清楚。

我正在运行SQL Server 2008 R2,我已经在使用IIS 7的主机上设置了我的报表服务器。如果我导航到http://name/Reportserver,我可以选择我创建的报告,运行它们,并看到正确显示的结果。

我的网页是这样的

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="CSI.REP.Core.Model"%>
<%@ Import Namespace="Microsoft.Reporting.WebForms" %>
<%@ Import Namespace="System.Security.Principal" %>
<%@ Import Namespace="System.Net" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<h2><a href="/Reporting">Back to Reports</a> / <%=ViewData["Report"]%></h2>
<form action="/Reporting/DateViewer" method="get">
Start Date: <input type="text" name="start" class="datepicker" value="<%=ViewData["Start"] %>" />
        End Date: <input type="text" name="end"  class="datepicker" value="<%=ViewData["End"] %>" />
        <input type="hidden" name="id" value="<%=ViewData["Report"] %>" />
        <input type="submit" class="button" value="Run" />
</form>
    <script runat="server" language="C#">
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
                if (ViewData["Start"] != null)
                {
                    var param = new List<ReportParameter>();
                    var start = new ReportParameter("start", ViewData["Start"].ToString());
                    var end = new ReportParameter("end", ViewData["End"].ToString());
                    param.Add(start);
                    param.Add(end);
                    ReportViewer1.Width = 1100;
                    ReportViewer1.Height = 900;
                    ReportViewer1.ProcessingMode = ProcessingMode.Remote;
                    IReportServerCredentials irsc =
                        new CustomReportCredentials(ConfigurationManager.AppSettings["ReportServerUser"],
                                                    ConfigurationManager.AppSettings["ReportServerPassword"], "Domainname");
                    ReportViewer1.ServerReport.ReportServerCredentials = irsc;
                    ReportViewer1.ServerReport.ReportServerUrl =
                        new Uri(string.Format("http://{0}/ReportServer",
                                              ConfigurationManager.AppSettings["ReportServerUrl"]));
                    ReportViewer1.ServerReport.ReportPath = string.Format("/{0}", ViewData["Report"]);
                    ReportViewer1.ServerReport.SetParameters(param);
                    ReportViewer1.ServerReport.Refresh();
                }

        }catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }

     </script>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
     <div>
        <rsweb:ReportViewer ID="ReportViewer1" runat="server" 
            ProcessingMode="Remote" 
            ShowPageNavigationControls="true" 
            ShowCredentialPrompts="False" 
            ShowDocumentMapButton="False" 
            ShowExportControls="true" 
            ShowFindControls="False" 
            ShowPrintButton="True" 
            ShowPromptAreaButton="False" 
            ShowRefreshButton="False" 
            ShowToolBar="true" 
            ShowZoomControl="False" 
            SizeToReportContent="True" 
            Width="100%" Height="600px"" /> 
         </rsweb:ReportViewer>
     </div>
   </form>
   </asp:Content>

与小提琴手,我注意到一对夫妇的奇怪的错误信息隐藏在<divs>设置为display:none

<noscript>&nbsp;Your browser does not support scripts or has been configured not to allow scripts.</noscript> 
Report Viewer Configuration Error
The Report Viewer Web Control HTTP Handler has not been registered in the application's  web.config file

但是,脚本是启用的,并且为了更好地衡量,我在浏览器的安全选项中将该站点添加到我的可信站点中。我试过火狐、IE和Chrome。我还向system.webserver/handlers部分添加了处理程序。当我单击Run时,报告似乎在运行,页面刷新,但绝对没有显示任何内容。当我没有设置参数时,它告诉我它缺少参数,所以看起来它只是没有正确渲染。什么好主意吗?

编辑

这是我的web.config的粘贴。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
    <section name="log4net"   type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
            <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
                <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
                <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
                <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
            </sectionGroup>
        </sectionGroup>
    </sectionGroup>
</configSections>
<system.net>
<mailSettings>
  <smtp from="***">
    <network defaultCredentials="false" host="****" password="****" userName="****" />
  </smtp>
</mailSettings>
</system.net>
<appSettings>
    <add key="ReportServerUser" value="***" />
    <add key="ReportServerPassword" value="***" />
    <add key="ReportServerUrl" value="192.168.0.19:80" />
    <add key="MailAccount" value="****" />
    <add key="MailPassword" value="****" />
    <add key="AppUrl" value="****" />
<connectionStrings>
        <add connectionString="Data Source=.'SQLEXPRESS;Database=CASH;User Id=***;Password=****;" name="***" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="false">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<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" />
</assemblies>
<buildProviders>
    <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</buildProviders>
    </compilation>
    <authentication mode="Forms">
        <forms loginUrl="~/Account/LogOn" timeout="240" />
    </authentication>
    <membership>
        <providers>
            <clear />
            <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/" />
        </providers>
    </membership>
    <profile>
        <providers>
            <clear />
            <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ApplicationServices" applicationName="/" />
        </providers>
    </profile>
    <roleManager enabled="false">
        <providers>
            <clear />
            <add connectionStringName="ApplicationServices" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
            <add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </providers>
    </roleManager>
    <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
        <error statusCode="403" redirect="NoAccess.htm" />
        <error statusCode="404" redirect="FileNotFound.htm" />
    </customErrors>
<customErrors mode="Off" />
        <pages>
        <controls>
            <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        </controls>
        <namespaces>
            <add namespace="System.Web.Mvc" />
            <add namespace="System.Web.Mvc.Ajax" />
            <add namespace="System.Web.Mvc.Html" />
            <add namespace="System.Web.Routing" />
            <add namespace="System.Linq" />
            <add namespace="System.Collections.Generic" />
        </namespaces>
    </pages>
    <httpHandlers>
        <remove verb="*" path="*.asmx" />
        <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
</httpHandlers>
    <httpModules>
        <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </httpModules>
</system.web>
<system.codedom>
    <compilers>
        <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <providerOption name="CompilerVersion" value="v3.5" />
            <providerOption name="WarnAsError" value="false" />
        </compiler>
        <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <providerOption name="CompilerVersion" value="v3.5" />
            <providerOption name="OptionInfer" value="true" />
            <providerOption name="WarnAsError" value="false" />
        </compiler>
    </compilers>
</system.codedom>
<system.web.extensions />
<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
        <remove name="ScriptModule" />
        <remove name="UrlRoutingModule" />
        <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
    <handlers>
        <remove name="WebServiceHandlerFactory-Integrated" />
        <remove name="ScriptHandlerFactory" />
        <remove name="ScriptHandlerFactoryAppServices" />
        <remove name="ScriptResource" />
        <remove name="UrlRoutingHandler" />
        <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                <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" /> 
                <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                     <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </handlers>
</system.webServer>
<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
  <file value="Logs'CASH.log" />
  <appendToFile value="true" />
  <rollingStyle value="Size" />
  <maximumFileSize value="100KB" />
  <maxSizeRollBackups value="5" />
  <staticLogFileName value="true" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date %level %thread %logger - %message%newline" />
  </layout>
</appender>
<root>
  <level value="ALL" />
  <appender-ref ref="RollingFile" />
</root>
</log4net>
</configuration>

ReportViewer未显示在页面上

可能是数据集或调用的存储过程有问题,请确保这些都是正确的否则会得到这个通用信息