ReportViewer未在页面上显示

时间:2013-06-05 17:47:27

标签: c# asp.net reportviewer

我已经在这几个小时了,还没有找到适合我的解决方案。我会尽可能清楚地解释。

我正在运行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>

使用fiddler,我注意到<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

但是,脚本已启用,并且在很好的情况下,我在浏览器的安全选项中将站点添加到我的受信任站点。我尝试过Firefox,IE和Chrome。我还将处理程序添加到system.webserver/handlers部分。当我单击“运行”时,报告似乎运行,页面刷新,但绝对没有显示。当我没有设置参数时,它告诉我它缺少参数,所以看起来它只是没有正确渲染。有什么想法吗?

修改

这是我的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>

1 个答案:

答案 0 :(得分:0)

您可能只是在调用数据集或存储过程时出错,请确保所有犹太人或您获得此通用消息