2012-11-27 62 views
1

我的確切問題報告here,並且一切似乎都正常。 這裏是我的web.config部分:報告已加載,但空白頁顯示爲

<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="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
    <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" /> 
    <add verb="*" path="Reserved.ReportViewerWebControl.axd" type ="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
</httpHandlers> 
<handlers> 
    <remove name="WebServiceHandlerFactory-Integrated" /> 
    <remove name="ScriptHandlerFactory" /> 
    <remove name="ScriptHandlerFactoryAppServices" /> 
    <remove name="ScriptResource" /> 
    <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="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="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> 

我得到一個空白頁,我看到這個錯誤消息時我查找的頁面的源代碼:

<h2> 
     Report Viewer Configuration Error 
</h2><p>The Report Viewer Web Control HTTP Handler has not been registered in the application'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> 

有人嗎?

謝謝。

+0

你是否在system.webServer部分添加了這個? –

回答

1

當我遇到這個問題時,我卸載了我安裝並重新安裝ReportViewer-2010的ReportViewer的每個版本並重新設置了web.config。你試過這個嗎?

另外,你是否加載UserControl中的ReportViewer?像這樣,

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<NMBSReportViewer.Models.SelectedReport>" %> 
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %> 
<form id="Form1" runat="server"> 
<asp:ScriptManager ID="ScriptManager1" runat="server" /> 
<rsweb:ReportViewer ID="ReportViewer1" runat="server" AsyncRendering="false" Height="480px" Width="100%" /> 
</form> 
<script runat="server"> 
    /* Prepare the ReportViewer Control to be Displayed */ 
    private void Page_Load(object sender, System.EventArgs e) 
    { 
     //Create/Get the Connection String 
     String ConnectionString = @"Data Source = localhost\SQLEXPRESS; Initial Catalog = School; Trusted_Connection=True;"; 

     //Create the Connection 
     System.Data.SqlClient.SqlConnection DbConn = new System.Data.SqlClient.SqlConnection(ConnectionString); 

     //Open the Connection 
     DbConn.Open(); 

     //Reset Control. 
     ReportViewer1.Reset(); 

     //Load Report Definition. 
     //Mine is from a string to load from a file do the following: 
     //ReportViewer1.LocalReport.ReportPath = "FilePath"; 
     System.IO.StringReader reader = new System.IO.StringReader(this.Model.ReportDefinition); 
     ReportViewer1.LocalReport.LoadReportDefinition(reader); 

     //Query String 
     String QueryString = this.Model.Query[i]; 

     //Create the SqlCommand Object 
     System.Data.SqlClient.SqlCommand QueryCommand = new System.Data.SqlClient.SqlCommand(QueryString, DbConn); 

     //Use the SqlCommand to create the DataReader Object. 
     System.Data.SqlClient.SqlDataReader QueryCommandReader = QueryCommand.ExecuteReader(); 

     //Create the Datatable. 
     System.Data.DataTable DataT = new System.Data.DataTable(); 

     //Load the Data into the Table. 
     DataT.Load(QueryCommandReader); 

     //Load Report Data. 
     ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource(dataSet.DataSetName, DataT)); 

     //Refresh Control. 
     ReportViewer1.LocalReport.Refresh(); 
} 
</script> 
+0

這不是那個人,我的web.config文件是正確的:/ – gabsferreira

+0

我改變了我的答案,我記得有這個問題只是記得我修復它的方式,我希望這有助於。我刪除了我的page_load函數並得到了類似的結果。 – Shelby115