问题描述
我的目标是显示来自远程 ssrs 报告服务器的报告。我正在尝试显示有关 ASP.NET MVC 框架的示例报告。 注意,我可以通过用户身份验证在浏览器上查看报告。
<%@ Register Assembly="Microsoft.ReportViewer.WebForms,Version=15.0.0.0,Culture=neutral,PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form runat="server">
<asp:ScriptManager runat="server"></asp:ScriptManager>
<rsweb:ReportViewer ID="MainReportViewer" runat="server" BackColor="White"
Font-Names="Verdana" Font-Size="8pt" InteractiveDeviceInfos=" (Collection)"
ProcessingMode="Remote" ShowBackButton="False" ShowFindControls="False"
ShowPageNavigationControls="False" SizetoReportContent="True"
ToolBarItemBorderColor="White" ToolBarItemHoverBackColor="White"
WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="100%">
<ServerReport reportserverUrl="" />
</rsweb:ReportViewer>
</form>
</body>
</html>
关于背后的代码
protected void Page_Load(object sender,EventArgs e) {
MainReportViewer.ProcessingMode = ProcessingMode.Remote;
IreportserverCredentials irsc = new CustomreportCredentials("username","password","https://servername.com");
MainReportViewer.ServerReport.reportserverCredentials = irsc;
MainReportViewer.ServerReport.reportserverUrl = new Uri("https://servername.com/reports");
MainReportViewer.ServerReport.ReportPath = "/report/Sample_Report_Project" + "/" + "Report_1";
}
在 CustomreportCredentials.cs 上
public class CustomreportCredentials : IreportserverCredentials
{
private string _UserName;
private string _PassWord;
private string _DomainName;
public CustomreportCredentials(string UserName,string PassWord,string DomainName)
{
_UserName = UserName;
_PassWord = PassWord;
_DomainName = DomainName;
}
public System.Security.Principal.WindowsIdentity ImpersonationUser
{
get { return null; }
}
public ICredentials NetworkCredentials
{
get { return new NetworkCredential(_UserName,_PassWord,_DomainName); }
}
public bool GetFormsCredentials(out Cookie authCookie,out string user,out string password,out string authority)
{
authCookie = null;
user = password = authority = null;
return false;
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)