我正在从报表服务器调用报表,项目成功运行但页面将为空。通过开发工具,我可以找到它获得的空间量。
以下是我正在使用的代码。
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
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</buildProviders>
并且在将报表查看器添加到页面时会自动添加一些程序集。
在system.webservices
下<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>
cs page
int dcid = 1;
ReportViewer1.Visible = true;
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
ReportViewer1.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportServer"].ToString());
Microsoft.Reporting.WebForms.ReportParameterInfoCollection paramInfo;
System.Collections.Generic.List<Microsoft.Reporting.WebForms.ReportParameter> paramList = new System.Collections.Generic.List<Microsoft.Reporting.WebForms.ReportParameter>();
paramList.Add(new Microsoft.Reporting.WebForms.ReportParameter("DCId", dcid.ToString(), false));
ReportViewer1.ServerReport.ReportPath = ConfigurationManager.AppSettings["ReportsFolder"].ToString() + "rpt_DCForm";
ReportViewer1.ServerReport.ReportServerCredentials = new Credentials(ConfigurationManager
.AppSettings["ReportUserName"].ToString(), ConfigurationManager
.AppSettings["ReportUserPwd"].ToString(), ConfigurationManager
.AppSettings["ReportserverDomain"].ToString());
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
ReportViewer1.ServerReport.SetParameters(paramList);
paramInfo = ReportViewer1.ServerReport.GetParameters();
ReportViewer1.ServerReport.Refresh();
凭据类
string _userName, _password, _domain;
public Credentials(string userName, string Password, string domain)
{
_userName = userName;
_password = Password;
_domain = domain;
}
#region IReportServerCredentials Members
public bool GetFormsCredentials(out System.Net.Cookie authCookie, out string userName, out string password, out string authority)
{
//userName = _userName;
//password = _password;
//authority = _domain;
//authCookie = new System.Net.Cookie(".ASPXAUTH", ".ASPXAUTH", "/", "Domain");
//return true;
authCookie = null;
userName = password = authority = null;
return false;
}
public System.Security.Principal.WindowsIdentity ImpersonationUser
{
get { return null; }
}
public System.Net.ICredentials NetworkCredentials
{
get { return new System.Net.NetworkCredential(_userName, _password, _domain); }
}
#endregion
相同的代码在我们的其他项目中正常工作。对于一个新的解决方案它不起作用。 请帮助我错过的。
提前致谢。