Url以PDF格式显示Sql Server Reporting Services

时间:2016-04-13 18:50:04

标签: c# asp.net pdf reporting-services

我正在尝试让Sql Server Report Services下载PDF格式的报告,以便我可以在浏览器中显示它们。

var uriDownload = new Uri("https://myServer.com/Reports/Pages/Folder.aspx?
                             ItemPath=item/path&rs:Format=pdf");
var strSavePath = "C:\\myFolder\\testAAA123.pdf";
var wcli = new System.Net.WebClient();
wcli.Credentials = new NetworkCredential("username", "password");
wcli.DownloadFile(uriDownload, strSavePath);
System.Diagnostics.Process.Start(strSavePath);

当我运行此代码时,我收到一条错误消息,指出无法打开PDF文件。当用pdf替换txt时,我得到一个包含aspx代码的文本文件,即使用Viewstate等。我猜这是因为url以aspx结尾。

当我尝试https://myServer.com/Reports/Pages/item/path&rs:Format=pdf之类的内容时,我会得到400 - Bad Request

请求返回PDF报表的URL应该如何?

感谢帮助。

0 个答案:

没有答案