我试图让SSRS生成PDF格式的报告,并捕获字节流以将它们保存到磁盘。如果必须发送的报表参数只有单个值,那么这种方法就可以了,但是如果必须发送特定参数的值数组,那么这种方法就不再有效了。
下面的工作很好,因为我只发送一年的价值。通过UI,Year参数将是multiselect。
string parameters = "rs:Command=Render&rs:format=PDF&Year=2018"
byte[] paramHeader = Encoding.ASCII.GetBytes(parameters);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(URL);
req.PreAuthenticate = true;
req.Credentials = new System.Net.NetworkCredential(
reportUser,
reportUserPW,
reportUserDomain);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = paramHeader.Length;
using (var stream = req.GetRequestStream())
{
stream.Write(paramHeader, 0, paramHeader.Length);
}
HttpWebResponse HttpWResp = (HttpWebResponse)req.GetResponse();
Stream fStream = HttpWResp.GetResponseStream();
File.WriteAllBytes(JobId.ToString() + "\\employeeName.pdf", copyStreamToByteArray(fStream));
string parameters = "rs:Command=Render&rs:format=PDF&Year=2018,2017,2016"
当我使用Reports Services UI查看它如何用Fiddler将参数发送到SSRS时,我尝试查看web流量,但无法从中获得任何有用的信息。它看起来像是在一个ViewState字符串中编码的。
如何在Post头中发送给定SSRS参数的值数组?