نوشته شده توسط
myaffa
اتصال به يك گزارش SSRS
ReportViewer RsViewer = newReportViewer();
RsViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
RsViewer.ShowCredentialPrompts = false;
RsViewer.ServerReport.ReportServerCredentials = newReportCredentials("UserName", "Password", "Domain");
RsViewer.ServerReport.ReportServerUrl = newUri("http://ServerAddress/ReportServer");
RsViewer.ServerReport.ReportPath = "/Path/FileName";
RsViewer.ProcessingMode = ProcessingMode.Remote;
RsViewer.ServerReport.Refresh();
در اين كد من از كلاس زير استفاده كرده ام
البته اين رو هم بايد بگم كه اين كلاسو خودم ننوشتم واز سايتهاي خارجي ديگه دانلود كردم
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
///<summary>
/// Summary description for ReportCredentials
///</summary>
publicclassReportCredentials : Microsoft.Reporting.WebForms.IReportServerCredentials
{
string _userName, _password, _domain;
public ReportCredentials(string userName, string password, string domain)
{
_userName = userName;
_password = password;
_domain = domain;
}
public System.Security.Principal.WindowsIdentity ImpersonationUser
{
get
{
returnnull;
}
}
public System.Net.ICredentials NetworkCredentials
{
get
{
returnnew System.Net.NetworkCredential(_userName, _password, _domain);
}
}
publicbool GetFormsCredentials(out System.Net.Cookie authCoki, outstring userName, outstring password, outstring authority)
{
userName = _userName;
password = _password;
authority = _domain;
authCoki = new System.Net.Cookie(".ASPXAUTH", ".ASPXAUTH", "/", _domain);
returntrue;
}
}