更新时间:2021-11-05 22:34:22
对不起,我不好-我忘了那是只读的
您必须设置 rptInventory.ServerReport.ReportServerCredentials
看一下此链接,其中完整说明了如何执行此操作(向下滚动至H.Laasri的答案)
http://int.social.msdn.microsoft. com/Forums/en/vsreportcontrols/thread/5aa7eee7-d4a7-427a-ab8d-7a3d4d4f0bf3 [
Sorry, my bad - I forgot that was Read Only
You''ve got to set rptInventory.ServerReport.ReportServerCredentials
Have a look at this link, which explains in full how to do this (scroll down to the answer by H.Laasri)
http://int.social.msdn.microsoft.com/Forums/en/vsreportcontrols/thread/5aa7eee7-d4a7-427a-ab8d-7a3d4d4f0bf3[^]
public partial class ReportViewerCredentials : IReportServerCredentials
{
private string _userName;
private string _password;
private string _domain;
public ReportViewerCredentials(string userName, string password, string domain)
{
_userName = userName;
_password = password;
_domain = domain;
}
public WindowsIdentity ImpersonationUser
{
get
{
//return null;
return WindowsIdentity.GetCurrent();
}
}
public ICredentials NetworkCredentials
{
get
{
return new NetworkCredential(_userName, _password, _domain);
}
}
public bool GetFormsCredentials(out Cookie authCookie,
out string userName, out string password,
out string authority)
{
authCookie = null;
userName = _userName;
password = _password;
authority = _domain;
// Not using form credentials
return false;
}
}
protected void Page_Load(object sender, EventArgs e)
{
ShowReport();
}
private void ShowReport()
{
try
{
ReportViewerCredentials rpCredentials = new ReportViewerCredentials(ConfigurationManager.AppSettings["ReportUser"], ConfigurationManager.AppSettings["ReportPassword"], ConfigurationManager.AppSettings["ReportDomain"]);
ReportViewer1.ServerReport.ReportServerCredentials = rpCredentials;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
是,在提供凭据后可以在服务器端正常工作.
但是当我尝试使用asp.net aspx页面时,会抛出上述错误.
rptInventory.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
ICredentials凭据=新的NetworkCredential("xyzuser","xyzpassword","globalaviatech.com");
rptInventory.ServerReport.ReportServerUrl =新的Uri("https://rs2k801.discountasp.net/ReportServer");
字符串strReport = @"/globalaviat/Reports/scm/SalesOfTerritory";
this.rptInventory.ServerReport.ReportPath = strReport;
Microsoft.Reporting.WebForms.ReportParameter [] @territoryid =新的Microsoft.Reporting.WebForms.ReportParameter [1];
@territoryid [0] =新的Microsoft.Reporting.WebForms.ReportParameter("territoryid",Session ["territoryid"].ToString());
rptInventory.ServerReport.SetParameters(@territoryid);
rptInventory.ServerReport.Refresh();
}
yes after giving credentials it is properly working on server side.
but when i try using my asp.net aspx page it is throwing the above error.
rptInventory.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
ICredentials credentials = new NetworkCredential("xyzuser", "xyzpassword", "globalaviatech.com");
rptInventory.ServerReport.ReportServerUrl = new Uri("https://rs2k801.discountasp.net/ReportServer");
string strReport = @"/globalaviat/Reports/scm/SalesOfTerritory";
this.rptInventory.ServerReport.ReportPath = strReport;
Microsoft.Reporting.WebForms.ReportParameter[] @territoryid = new Microsoft.Reporting.WebForms.ReportParameter[1];
@territoryid[0] = new Microsoft.Reporting.WebForms.ReportParameter("territoryid", Session["territoryid"].ToString());
rptInventory.ServerReport.SetParameters(@territoryid);
rptInventory.ServerReport.Refresh();
}
您似乎尚未将凭据设置为ServerReport
例如
rptInventory.ServerReport.ReportServerCredentials =凭据;
http://www.devx.com/dotnet/Article/30424/1763/page/3 [^ ]
You don''t seem to have set the credentials to the ServerReport
e.g.
rptInventory.ServerReport.ReportServerCredentials = credentials;
http://www.devx.com/dotnet/Article/30424/1763/page/3[^]