我有一个 SSRS 报告 URL,如果我在浏览器中输入该 URL,则会显示带有打印和保存选项的 SSRS 报告,如下所示:
这在浏览器上运行良好。
我想要的是,页面上有一个按钮.cshtml,因此通过单击该按钮,我需要在客户端浏览器上下载报告。
网址:http://xyz/ReportS/report/UAT/SampleReport_V1?Srno=X123
我尝试过的:
通过设置&rs:Format=PDF并从 Asp.Net Core 应用程序发出 HTTP 请求,但它生成了 PDF,但格式已损坏。
代码:
public void Download_SSRSInPDF()
{
string URL = "http://xyz/ReportS/report/UAT/SampleReport_V1";
string Command = "Render";
string Format = "PDF";
URL = URL + "?SrNo=X123&rs:Command=" + Command + "&rs:Format=" + Format;
System.Net.HttpWebRequest Req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(URL);
Req.Credentials = System.Net.CredentialCache.DefaultCredentials;
Req.Method = "GET";
string path = @"E:\New folder\Test.pdf";
System.Net.WebResponse objResponse = Req.GetResponse();
System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Create);
System.IO.Stream stream = objResponse.GetResponseStream(); …Run Code Online (Sandbox Code Playgroud)