pdf
としてレポートを実行しようとしています。asp.net c#
です。私はsqlauth cookie
を除いて、すべてがうまくいっています。 iframe
を使用してダミーのレポートをレンダリングした場合、コードビハインドでそのsqlAuthCookie
クッキー(レポートサーバーで設定)を使用しても動作しますので、構文とメソッドなどが正しいことがわかります。私がする必要があるのは、sqlauth cookie
をReportExecution ServiceのCookieコンテナに追加するか、その他の資格を渡す方法です。私はForms Authentication
を使用しています。私はjquery ajax
コールを持つashx
ハンドラを使ってレポートを実行しています。ここに私のコードの背後にあるページがあります。SSRS実行サービスのためにsqlAuthCookieを設定してください
public void ProcessRequest(HttpContext context)
{
// 8863443a-06d6-4aeb-8fa8-43be545da1a3
var rs = new ReportExecutionService();
rs.Credentials = CredentialCache.DefaultCredentials;
//rs.Credentials = new NetworkCredential("zachariah.curtis", "password", "AGLO");
rs.Url = ConfigurationManager.AppSettings["ReportExecutionURL"];
NetworkCredential creds = rs.Credentials.GetCredential(context.Request.Url, context.User.Identity.AuthenticationType);
rs.LogonUser(creds.UserName, creds.Password, null);
var cookies = context.Request.Cookies.AllKeys.ToList();
var cookies3 = rs.CookieContainer.GetCookies(new Uri(rs.Url));
var sqlauth = context.Request.Cookies["sqlAuthCookie"];
rs.CookieContainer = new CookieContainer();
cookies.ForEach(delegate(String item)
{
rs.CookieContainer.Add(new Cookie(context.Request.Cookies[item].Name, context.Request.Cookies[item].Value, context.Request.Cookies[item].Path, context.Request.Cookies[item].Domain ?? ".usda.gov"));
rs.CookieContainer.Add(new Cookie("sqlAuthCookie", "A78B8A2D714BF058DF7258927717A4D34FA9F8A0BA54FCCB006543DEBF755D2670636E172675107A9FCAF77F66A0E7E2EE4321464602C7E61138C224B8612B05E12DC1DFF878E8748CE267FF19839198", "/", "iasdev.dev.sc.egov.usda.gov"));
});
// Render arguments
byte[] result = null;
// Make sure you use your correct org database name of the following line
string reportPath = "/ProTractsCMT/TestReport";
var contractId = context.Request["ContractId"];
string format = "PDF";
string historyID = null;
string devInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
// Prepare report parameter.
ParameterValue[] parameters = new ParameterValue[1];
parameters[0] = new ParameterValue();
parameters[0].Name = "@CONTRACTID";
parameters[0].Value = contractId;
DataSourceCredentials[] credentials = null;
string showHideToggle = null;
string encoding;
string mimeType;
string extension;
Warning[] warnings = null;
ParameterValue[] reportHistoryParameters = null;
string[] streamIDs = null;
ExecutionInfo execInfo = new ExecutionInfo();
ExecutionHeader execHeader = new ExecutionHeader();
rs.ExecutionHeaderValue = execHeader;
execInfo = rs.LoadReport(reportPath, historyID);
//rs.SetExecutionParameters(parameters, "en-us");
string SessionId = rs.ExecutionHeaderValue.ExecutionID;
Console.WriteLine("SessionID: {0}", rs.ExecutionHeaderValue.ExecutionID);
try
{
result = rs.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
execInfo = rs.GetExecutionInfo();
Console.WriteLine("Execution date and time: {0}", execInfo.ExecutionDateTime);
}
catch (SoapException err)
{
Console.WriteLine(err.Detail.OuterXml);
}
context.Response.ContentType = "text/plain";
// save rendered pdf to db
if (new calculations().SaveReport(result))
{
context.Response.Write("true");
}
else
{
context.Response.Write("true");
}
}
rs.CookieContainer.Add(new Cookie("sqlAuthCookie"
はどこにあるのか分かります。してください助けてください!皆さんありがとう!