我正在报告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 <add verb="*" path="Reserved.ReportViewerWebControl.axd" type = "Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> to the system.web/httpHandlers section of the web.config file, or add <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" /> to the system.webServer/handlers section for Internet Information Services 7 or later.</p>
任何?
感谢。
答案 0 :(得分:1)
当我遇到此问题时,我取消了我安装的每个版本的ReportViewer并重新安装了ReportViewer-2010并重新编写了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>