是的,我想将 SSRS 报告导出到 PDF 并从我的操作中返回,我没有任何报告查看器。请建议我如何实现这一点。到目前为止,我已经做到了
public void SqlServerReport()
{
NetworkCredential nwc = new NetworkCredential("username", "password", "domain");
WebClient client = new WebClient();
client.Credentials = nwc;
string reportURL = "http://servername/ReportServer/reportfolder/StateReport&rs:Command=Render&rs:Format=PDF";
Byte[] pageData = client.DownloadData(reportURL);
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "attachment; filename=" + DateTime.Now);
Response.BinaryWrite(pageData);
Response.Flush();
Response.End();
}
上面的代码抛出异常
"The remote server returned an error: (401) Unauthorized."
我的问题是
1)我是否朝着正确的方向前进?
2)有没有更好的选择来实现这一目标?