我刚刚开始在 SSRS 工作,遇到了一个非常奇怪的问题,即当我调用报表服务器 URL 时,即 localhost/Reports
此 URL 需要用户名和密码的身份验证窗口。像这样。
如果我在这种情况下提交了本地系统用户帐户信息,它将出现我们想要的报告服务器屏幕。像这样。
我创建了一个演示 Web 应用程序,并在我ReportViewer
用来显示报告和配置它的 default.aspx 页面中。这是我正在使用
Default.aspx
页面的代码
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="100%">
</rsweb:ReportViewer>
Default.aspx.cs
页
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
IReportServerCredentials irsc = new CustomReportCredentials("username", "password", "India");
ReportViewer1.ServerReport.ReportServerCredentials = irsc;
ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://localhost/Reports");
ReportViewer1.ServerReport.ReportPath = "/SSRS_Demo/Report_CaseMain";
ReportViewer1.ServerReport.Refresh();
CustomReportCredentials.cs
班级
public class CustomReportCredentials : IReportServerCredentials
{
// local variable for network credential.
private string _UserName;
private string _PassWord;
private string _DomainName;
public CustomReportCredentials(string UserName, string PassWord, string DomainName)
{
_UserName = UserName;
_PassWord = PassWord;
_DomainName = DomainName;
}
public WindowsIdentity ImpersonationUser
{
get
{
return null; // not use ImpersonationUser
}
}
public ICredentials NetworkCredentials
{
get
{
// use NetworkCredentials
return new NetworkCredential(_UserName, _PassWord, _DomainName);
}
}
public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority)
{
// not use FormsCredentials unless you have implements a custom autentication.
authCookie = null;
user = password = authority = null;
return false;
}
}
当我在这种情况下运行这个网络应用程序时,它会给我一个错误,即
请帮我看看我将如何解决这些所有错误......