java ssrs匿名_SSRS 报表 如何匿名查看

本文介绍如何在ASP.NET应用程序中配置报告查看器以从报表服务器加载报表,并设置必要的凭证及参数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

public partial classOne : System.Web.UI.Page

{protected void Page_Load(objectsender, EventArgs e)

{if (!IsPostBack)

{

ReportParameter para= new ReportParameter("ReportParameter1", "1");

ReportViewer1.ServerReport.ReportServerCredentials= newMyReportServerCredentials();

ReportViewer1.ServerReport.ReportServerUrl= new Uri("http://报表服务器地址/reportserver");

ReportViewer1.ServerReport.ReportPath= "/报表地址";

ReportViewer1.ServerReport.SetParameters(newReportParameter[] { para });

}

}

}

[Serializable]public sealed classMyReportServerCredentials : IReportServerCredentials

{publicWindowsIdentity ImpersonationUser

{get{//Use the default Windows user. Credentials will be//provided by the NetworkCredentials property.

return null;

}

}publicICredentials NetworkCredentials

{get{//Read the user information from the Web.config file.//By reading the information on demand instead of//storing it, the credentials will not be stored in//session, reducing the vulnerable surface area to the//Web.config file, which can be secured with an ACL.//User name

string userName =ConfigurationManager.AppSettings

["myReportViewerUser"];if (string.IsNullOrEmpty(userName))throw newException("Missing user name from web.config file");//Password

string password =ConfigurationManager.AppSettings

["MyReportViewerPassword"];if (string.IsNullOrEmpty(password))throw newException("Missing password from web.config file");//Domain

string domain =ConfigurationManager.AppSettings

["MyReportViewerDomain"];if (string.IsNullOrEmpty(domain))throw newException("Missing domain from web.config file");return newNetworkCredential(userName, password, domain);

}

}public bool GetFormsCredentials(outCookie authCookie,out string userName, out stringpassword,out stringauthority)

{

authCookie= null;

userName= null;

password= null;

authority= null;//Not using form credentials

return false;

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值